_id
stringlengths
2
7
title
stringlengths
1
88
partition
stringclasses
3 values
text
stringlengths
75
19.8k
language
stringclasses
1 value
meta_information
dict
q48700
BAMIndex.get_unaligned_lines
train
def get_unaligned_lines(self): """get the lines that are not aligned""" sys.stderr.write("error unimplemented get_unaligned_lines\n") sys.exit() return [self._lines[x-1] for x in self._unaligned]
python
{ "resource": "" }
q48701
ItemBase._generate
train
def _generate(self): u"""overrided in each modules.""" self._data['key'] = self.key self._data['value'] = self.value self._data['host'] = self.host self._data['clock'] = self.clock
python
{ "resource": "" }
q48702
compose
train
def compose(first_func, second_func): """ Compose two functions. Documentation is retrieved from the first one. Parameters ---------- first_func The first, main, function. second_func The second, (less important) function. Returns function A new function. ...
python
{ "resource": "" }
q48703
escape_string
train
def escape_string(text): """Remove problematic characters. Parameters ---------- text A string with potentially problematic characters. Returns ------- string The text with characters removed. Examples ------- >>> s = r'hello_world$here' >>> escape_string(...
python
{ "resource": "" }
q48704
chunker
train
def chunker(iterable, size=5, fill=''): """Chunk the iterable. Parameters ---------- iterable A list. size The size of the chunks. fill Fill value if the chunk is not of length 'size'. Yields ------- chunk A chunk of length 'size'. Examples ...
python
{ "resource": "" }
q48705
round_to_nearest
train
def round_to_nearest(number, nearest=1): """Round 'number' to the nearest multiple of 'nearest'. Parameters ---------- number A real number to round. nearest Number to round to closes multiple of. Returns ------- rounded A rounded number. Examples ----...
python
{ "resource": "" }
q48706
all_equal
train
def all_equal(iterable): """Checks whether all items in an iterable are equal. Parameters ---------- iterable An iterable, e.g. a string og a list. Returns ------- boolean True or False. Examples ------- >>> all_equal([2, 2, 2]) True >>> all_equal([...
python
{ "resource": "" }
q48707
min_between
train
def min_between(min_reps=3, max_reps=8, percentile=0.33): """Function to decide the minimum number of reps to perform given `min_reps` and `max_rep`. Parameters ---------- min_reps The minimum number of repeitions. max_reps The maximum number of repetitions. percentile ...
python
{ "resource": "" }
q48708
spread
train
def spread(iterable): """Returns the maximal spread of a sorted list of numbers. Parameters ---------- iterable A list of numbers. Returns ------- max_diff The maximal difference when the iterable is sorted. Examples ------- >>> spread([1, 11, 13, 15]) 10 ...
python
{ "resource": "" }
q48709
Gravatar.secure
train
def secure(self, value): """Set the secure parameter and regenerate the thumbnail link.""" self._secure = value self._thumb = self._link_to_img()
python
{ "resource": "" }
q48710
Gravatar.rating
train
def rating(self, value): """Set the rating parameter and regenerate the thumbnail link.""" self._rating = value self._thumb = self._link_to_img()
python
{ "resource": "" }
q48711
Gravatar.size
train
def size(self, value): """Set the size parameter and regenerate the thumbnail link.""" self._size = value self._thumb = self._link_to_img()
python
{ "resource": "" }
q48712
Gravatar.default
train
def default(self, value): """Set the default parameter and regenerate the thumbnail link.""" self._default = value self._thumb = self._link_to_img()
python
{ "resource": "" }
q48713
Gravatar._link_to_img
train
def _link_to_img(self): """ Generates a link to the user's Gravatar. >>> Gravatar('gridaphobe@gmail.com')._link_to_img() 'http://www.gravatar.com/avatar/16b87da510d278999c892cdbdd55c1b6?s=80&r=g' """ # make sure options are valid if self.rating.lower() no...
python
{ "resource": "" }
q48714
Gravatar._get_profile
train
def _get_profile(self): """ Retrieves the profile data of the user and formats it as a Python dictionary. """ url = PROFILE_URL + self.hash + '.json' try: profile = json.load(urlopen(url)) # set the profile as an instance variable self....
python
{ "resource": "" }
q48715
parse_url
train
def parse_url(url): """Return a clean URL. Remove the prefix for the Auth URL if Found. :param url: :return aurl: """ if url.startswith(('http', 'https', '//')): if url.startswith('//'): return urlparse.urlparse(url, scheme='http') else: return urlparse.urlpa...
python
{ "resource": "" }
q48716
html_encode
train
def html_encode(path): """Return an HTML encoded Path. :param path: ``str`` :return: ``str`` """ if sys.version_info > (3, 2, 0): return urllib.parse.quote(utils.ensure_string(path)) else: return urllib.quote(utils.ensure_string(path))
python
{ "resource": "" }
q48717
MakeRequest._get_url
train
def _get_url(url): """Returns a URL string. If the ``url`` parameter is a ParsedResult from `urlparse` the full url will be unparsed and made into a string. Otherwise the ``url`` parameter is returned as is. :param url: ``str`` || ``object`` """ if isinstance(ur...
python
{ "resource": "" }
q48718
MakeRequest._report_error
train
def _report_error(self, request, exp): """When making the request, if an error happens, log it.""" message = ( "Failure to perform %s due to [ %s ]" % (request, exp) ) self.log.fatal(message) raise requests.RequestException(message)
python
{ "resource": "" }
q48719
MakeRequest.head
train
def head(self, url, headers=None, kwargs=None): """Make a HEAD request. To make a HEAD request pass, ``url`` :param url: ``str`` :param headers: ``dict`` :param kwargs: ``dict`` """ return self._request( method='head', url=url, ...
python
{ "resource": "" }
q48720
MakeRequest.patch
train
def patch(self, url, headers=None, body=None, kwargs=None): """Make a PATCH request. To make a PATCH request pass, ``url`` :param url: ``str`` :param headers: ``dict`` :param body: ``object`` :param kwargs: ``dict`` """ return self._request( ...
python
{ "resource": "" }
q48721
MakeRequest.delete
train
def delete(self, url, headers=None, kwargs=None): """Make a DELETE request. To make a DELETE request pass, ``url`` :param url: ``str`` :param headers: ``dict`` :param kwargs: ``dict`` """ return self._request( method='delete', url=url, ...
python
{ "resource": "" }
q48722
MakeRequest.option
train
def option(self, url, headers=None, kwargs=None): """Make a OPTION request. To make a OPTION request pass, ``url`` :param url: ``str`` :param headers: ``dict`` :param kwargs: ``dict`` """ return self._request( method='option', url=url, ...
python
{ "resource": "" }
q48723
DateParser.__generate
train
def __generate(self): """Generates dates patterns""" base = [] texted = [] for pat in ALL_PATTERNS: data = pat.copy() data['pattern'] = data['pattern'] data['right'] = True data['basekey'] = data['key'] base.append(data) ...
python
{ "resource": "" }
q48724
DateParser.parse
train
def parse(self, text, noprefix=False): """Parse date and time from given date string. :param text: Any human readable string :type date_string: str|unicode :param noprefix: If set True than doesn't use prefix based date patterns filtering settings :type n...
python
{ "resource": "" }
q48725
Migration.forwards
train
def forwards(self, orm): "Perform a 'safe' load using Avocado's backup utilities." from avocado.core import backup backup.safe_load(u'0002_avocado_metadata', backup_path=None, using='default')
python
{ "resource": "" }
q48726
IdList.get_next_id
train
def get_next_id(self): """Gets the next Id in this list. return: (osid.id.Id) - the next Id in this list. The has_next() method should be used to test that a next Id is available before calling this method. raise: IllegalState - no more elements available in thi...
python
{ "resource": "" }
q48727
CatalogQuerySession.get_catalogs_by_query
train
def get_catalogs_by_query(self, catalog_query): """Gets a list of ``Catalogs`` matching the given catalog query. arg: catalog_query (osid.cataloging.CatalogQuery): the catalog query return: (osid.cataloging.CatalogList) - the returned ``CatalogList`` r...
python
{ "resource": "" }
q48728
CatalogAdminSession.can_create_catalog_with_record_types
train
def can_create_catalog_with_record_types(self, catalog_record_types): """Tests if this user can create a single ``Catalog`` using the desired record types. While ``CatalogingManager.getCatalogRecordTypes()`` can be used to examine which records are supported, this method tests which rec...
python
{ "resource": "" }
q48729
CatalogAdminSession.update_catalog
train
def update_catalog(self, catalog_form): """Updates an existing catalog. arg: catalog_form (osid.cataloging.CatalogForm): the form containing the elements to be updated raise: IllegalState - ``catalog_form`` already used in an update transaction raise:...
python
{ "resource": "" }
q48730
CatalogAdminSession.delete_catalog
train
def delete_catalog(self, catalog_id): """Deletes a ``Catalog``. arg: catalog_id (osid.id.Id): the ``Id`` of the ``Catalog`` to remove raise: NotFound - ``catalog_id`` not found raise: NullArgument - ``catalog_id`` is ``null`` raise: OperationFailed - unable...
python
{ "resource": "" }
q48731
CatalogAdminSession.alias_catalog
train
def alias_catalog(self, catalog_id, alias_id): """Adds an ``Id`` to a ``Catalog`` for the purpose of creating compatibility. The primary ``Id`` of the ``Catalog`` is determined by the provider. The new ``Id`` performs as an alias to the primary ``Id``. If the alias is a pointer to anoth...
python
{ "resource": "" }
q48732
CatalogHierarchySession.get_root_catalogs
train
def get_root_catalogs(self): """Gets the root catalogs in the catalog hierarchy. A node with no parents is an orphan. While all catalog ``Ids`` are known to the hierarchy, an orphan does not appear in the hierarchy unless explicitly added as a root node or child of another node....
python
{ "resource": "" }
q48733
CatalogHierarchySession.has_parent_catalogs
train
def has_parent_catalogs(self, catalog_id): """Tests if the ``Catalog`` has any parents. arg: catalog_id (osid.id.Id): a catalog ``Id`` return: (boolean) - ``true`` if the catalog has parents, ``false`` otherwise raise: NotFound - ``catalog_id`` is not found r...
python
{ "resource": "" }
q48734
CatalogHierarchySession.is_parent_of_catalog
train
def is_parent_of_catalog(self, id_, catalog_id): """Tests if an ``Id`` is a direct parent of a catalog. arg: id (osid.id.Id): an ``Id`` arg: catalog_id (osid.id.Id): the ``Id`` of a catalog return: (boolean) - ``true`` if this ``id`` is a parent of ``catalog_id,`` ...
python
{ "resource": "" }
q48735
CatalogHierarchySession.get_parent_catalog_ids
train
def get_parent_catalog_ids(self, catalog_id): """Gets the parent ``Ids`` of the given catalog. arg: catalog_id (osid.id.Id): a catalog ``Id`` return: (osid.id.IdList) - the parent ``Ids`` of the catalog raise: NotFound - ``catalog_id`` is not found raise: NullArgument - ``c...
python
{ "resource": "" }
q48736
CatalogHierarchySession.get_parent_catalogs
train
def get_parent_catalogs(self, catalog_id): """Gets the parent catalogs of the given ``id``. arg: catalog_id (osid.id.Id): the ``Id`` of the ``Catalog`` to query return: (osid.cataloging.CatalogList) - the parent catalogs of the ``id`` raise: NotFound ...
python
{ "resource": "" }
q48737
CatalogHierarchySession.is_ancestor_of_catalog
train
def is_ancestor_of_catalog(self, id_, catalog_id): """Tests if an ``Id`` is an ancestor of a catalog. arg: id (osid.id.Id): an ``Id`` arg: catalog_id (osid.id.Id): the ``Id`` of a catalog return: (boolean) - ``true`` if this ``id`` is an ancestor of ``catalogId``. ...
python
{ "resource": "" }
q48738
CatalogHierarchySession.has_child_catalogs
train
def has_child_catalogs(self, catalog_id): """Tests if a catalog has any children. arg: catalog_id (osid.id.Id): a ``catalog_id`` return: (boolean) - ``true`` if the ``catalog_id`` has children, ``false`` otherwise raise: NotFound - ``catalog_id`` is not found ...
python
{ "resource": "" }
q48739
CatalogHierarchySession.is_child_of_catalog
train
def is_child_of_catalog(self, id_, catalog_id): """Tests if a catalog is a direct child of another. arg: id (osid.id.Id): an ``Id`` arg: catalog_id (osid.id.Id): the ``Id`` of a catalog return: (boolean) - ``true`` if the ``id`` is a child of ``catalog_id,`` ``fal...
python
{ "resource": "" }
q48740
CatalogHierarchySession.get_child_catalog_ids
train
def get_child_catalog_ids(self, catalog_id): """Gets the child ``Ids`` of the given catalog. arg: catalog_id (osid.id.Id): the ``Id`` to query return: (osid.id.IdList) - the children of the catalog raise: NotFound - ``catalog_id`` is not found raise: NullArgument - ``catalo...
python
{ "resource": "" }
q48741
CatalogHierarchySession.get_child_catalogs
train
def get_child_catalogs(self, catalog_id): """Gets the child catalogs of the given ``id``. arg: catalog_id (osid.id.Id): the ``Id`` of the ``Catalog`` to query return: (osid.cataloging.CatalogList) - the child catalogs of the ``id`` raise: NotFound - a...
python
{ "resource": "" }
q48742
CatalogHierarchySession.is_descendant_of_catalog
train
def is_descendant_of_catalog(self, id_, catalog_id): """Tests if an ``Id`` is a descendant of a catalog. arg: id (osid.id.Id): an ``Id`` arg: catalog_id (osid.id.Id): the ``Id`` of a catalog return: (boolean) - ``true`` if the ``id`` is a descendant of the ``catalo...
python
{ "resource": "" }
q48743
CatalogHierarchySession.get_catalog_nodes
train
def get_catalog_nodes(self, catalog_id, ancestor_levels, descendant_levels, include_siblings): """Gets a portion of the hierarchy for the given catalog. arg: catalog_id (osid.id.Id): the ``Id`` to query arg: ancestor_levels (cardinal): the maximum number of ancestor levels...
python
{ "resource": "" }
q48744
CatalogHierarchyDesignSession.add_root_catalog
train
def add_root_catalog(self, catalog_id): """Adds a root catalog. arg: catalog_id (osid.id.Id): the ``Id`` of a catalog raise: AlreadyExists - ``catalog_id`` is already in hierarchy raise: NotFound - ``catalog_id`` not found raise: NullArgument - ``catalog_id`` is ``null`` ...
python
{ "resource": "" }
q48745
CatalogHierarchyDesignSession.remove_root_catalog
train
def remove_root_catalog(self, catalog_id): """Removes a root catalog. arg: catalog_id (osid.id.Id): the ``Id`` of a catalog raise: NotFound - ``catalog_id`` is not a root raise: NullArgument - ``catalog_id`` is ``null`` raise: OperationFailed - unable to complete request ...
python
{ "resource": "" }
q48746
CatalogHierarchyDesignSession.add_child_catalog
train
def add_child_catalog(self, catalog_id, child_id): """Adds a child to a catalog. arg: catalog_id (osid.id.Id): the ``Id`` of a catalog arg: child_id (osid.id.Id): the ``Id`` of the new child raise: AlreadyExists - ``catalog_id`` is already a parent of ``child_id``...
python
{ "resource": "" }
q48747
CatalogHierarchyDesignSession.remove_child_catalog
train
def remove_child_catalog(self, catalog_id, child_id): """Removes a child from a catalog. arg: catalog_id (osid.id.Id): the ``Id`` of a catalog arg: child_id (osid.id.Id): the ``Id`` of the new child raise: NotFound - ``catalog_id`` is not a parent of ``child_id`` ...
python
{ "resource": "" }
q48748
CatalogHierarchyDesignSession.remove_child_catalogs
train
def remove_child_catalogs(self, catalog_id): """Removes all children from a catalog. arg: catalog_id (osid.id.Id): the ``Id`` of a catalog raise: NotFound - ``catalog_id`` is not in hierarchy raise: NullArgument - ``catalog_id`` is ``null`` raise: OperationFailed - unable ...
python
{ "resource": "" }
q48749
split_hostmask
train
def split_hostmask(hostmask): """Splits a nick@host string into nick and host.""" nick, _, host = hostmask.partition('@') nick, _, user = nick.partition('!') return nick, user or None, host or None
python
{ "resource": "" }
q48750
preprocess_histogram
train
def preprocess_histogram(hist, values, edges): """Handles edge-cases and extremely-skewed histograms""" # working with extremely skewed histograms if np.count_nonzero(hist) == 0: # all of them above upper bound if np.all(values >= edges[-1]): hist[-1] = 1 # all of them b...
python
{ "resource": "" }
q48751
check_array
train
def check_array(array): "Converts to flattened numpy arrays and ensures its not empty." if len(array) < 1: raise ValueError('Input array is empty! Must have atleast 1 element.') return np.ma.masked_invalid(array).flatten()
python
{ "resource": "" }
q48752
Account.list
train
def list(self): """ Return a list of Accounts from Toshl for the current user """ response = self.client._make_request('/accounts') response = response.json() return self.client._list_response(response)
python
{ "resource": "" }
q48753
Account.search
train
def search(self, account_name): """ Get a list of all the Accounts for the current user and return the ID of the one with the specified name. """ accounts = self.list() for a in accounts: if a['name'] == account_name: return a['id']
python
{ "resource": "" }
q48754
Account.get
train
def get(self, account_id): """ Return a specific account given its ID """ response = self.client._make_request('/accounts/{0}'.format(account_id)) return response.json()
python
{ "resource": "" }
q48755
AssessmentAuthoringManager.get_assessment_part_bank_assignment_session
train
def get_assessment_part_bank_assignment_session(self): """Gets the ``OsidSession`` associated with assigning assessment part to bank. return: (osid.assessment.authoring.AssessmentPartBankAssignmentS ession) - an ``AssessmentPartBankAssignmentSession`` raise: Ope...
python
{ "resource": "" }
q48756
AssessmentAuthoringManager.get_sequence_rule_lookup_session
train
def get_sequence_rule_lookup_session(self): """Gets the ``OsidSession`` associated with the sequence rule lookup service. return: (osid.assessment.authoring.SequenceRuleLookupSession) - a ``SequenceRuleLookupSession`` raise: OperationFailed - unable to complete request ...
python
{ "resource": "" }
q48757
AssessmentAuthoringManager.get_sequence_rule_admin_session
train
def get_sequence_rule_admin_session(self): """Gets the ``OsidSession`` associated with the sequence rule administration service. return: (osid.assessment.authoring.SequenceRuleAdminSession) - a ``SequenceRuleAdminSession`` raise: OperationFailed - unable to complete request ...
python
{ "resource": "" }
q48758
AssessmentAuthoringManager.get_sequence_rule_admin_session_for_bank
train
def get_sequence_rule_admin_session_for_bank(self, bank_id): """Gets the ``OsidSession`` associated with the sequence rule administration service for the given bank. arg: bank_id (osid.id.Id): the ``Id`` of the ``Bank`` return: (osid.assessment.authoring.SequenceRuleAdminSession) - a ...
python
{ "resource": "" }
q48759
AssessmentAuthoringProxyManager.get_assessment_part_lookup_session
train
def get_assessment_part_lookup_session(self, proxy): """Gets the ``OsidSession`` associated with the assessment part lookup service. arg: proxy (osid.proxy.Proxy): a proxy return: (osid.assessment.authoring.AssessmentPartLookupSession) - an ``AssessmentPartLookupSession`` ...
python
{ "resource": "" }
q48760
AssessmentAuthoringProxyManager.get_assessment_part_lookup_session_for_bank
train
def get_assessment_part_lookup_session_for_bank(self, bank_id, proxy): """Gets the ``OsidSession`` associated with the assessment part lookup service for the given bank. arg: bank_id (osid.id.Id): the ``Id`` of the ``Bank`` arg: proxy (osid.proxy.Proxy): a proxy return: (osid.asse...
python
{ "resource": "" }
q48761
AssessmentAuthoringProxyManager.get_assessment_part_query_session
train
def get_assessment_part_query_session(self, proxy): """Gets the ``OsidSession`` associated with the assessment part query service. arg: proxy (osid.proxy.Proxy): a proxy return: (osid.assessment.authoring.AssessmentPartQuerySession) - an ``AssessmentPartQuerySession`` ...
python
{ "resource": "" }
q48762
AssessmentAuthoringProxyManager.get_assessment_part_query_session_for_bank
train
def get_assessment_part_query_session_for_bank(self, bank_id, proxy): """Gets the ``OsidSession`` associated with the assessment part query service for the given bank. arg: bank_id (osid.id.Id): the ``Id`` of the ``Bank`` arg: proxy (osid.proxy.Proxy): a proxy return: (osid.assess...
python
{ "resource": "" }
q48763
AssessmentAuthoringProxyManager.get_assessment_part_admin_session
train
def get_assessment_part_admin_session(self, proxy): """Gets the ``OsidSession`` associated with the assessment part administration service. arg: proxy (osid.proxy.Proxy): a proxy return: (osid.assessment.authoring.AssessmentPartAdminSession) - an ``AssessmentPartAdminSession`...
python
{ "resource": "" }
q48764
AssessmentAuthoringProxyManager.get_assessment_part_admin_session_for_bank
train
def get_assessment_part_admin_session_for_bank(self, bank_id, proxy): """Gets the ``OsidSession`` associated with the assessment part administration service for the given bank. arg: bank_id (osid.id.Id): the ``Id`` of the ``Bank`` arg: proxy (osid.proxy.Proxy): a proxy return: (os...
python
{ "resource": "" }
q48765
AssessmentAuthoringProxyManager.get_sequence_rule_lookup_session_for_bank
train
def get_sequence_rule_lookup_session_for_bank(self, bank_id, proxy): """Gets the ``OsidSession`` associated with the sequence rule lookup service for the given bank. arg: bank_id (osid.id.Id): the ``Id`` of the ``Bank`` arg: proxy (osid.proxy.Proxy): a proxy return: (osid.assessme...
python
{ "resource": "" }
q48766
AssessmentAuthoringProxyManager.get_assessment_part_item_session_for_bank
train
def get_assessment_part_item_session_for_bank(self, bank_id, proxy): """Gets the ``OsidSession`` associated with the assessment part item service for the given bank. arg: bank_id (osid.id.Id): the ``Id`` of the ``Bank`` return: (osid.assessment.authoring.AssessmentPartItemSession) ...
python
{ "resource": "" }
q48767
AssessmentAuthoringProxyManager.get_assessment_part_item_design_session_for_bank
train
def get_assessment_part_item_design_session_for_bank(self, bank_id, proxy): """Gets the ``OsidSession`` associated with the assessment part item design service for the given bank. arg: bank_id (osid.id.Id): the ``Id`` of the ``Bank`` return: (osid.assessment.authoring.AssessmentPartItemDesig...
python
{ "resource": "" }
q48768
deprecated
train
def deprecated(operation=None): """ Mark an operation deprecated. """ def inner(o): o.deprecated = True return o return inner(operation) if operation else inner
python
{ "resource": "" }
q48769
response
train
def response(status, description, resource=DefaultResource): # type: (HTTPStatus, str, Optional[Resource]) -> Callable """ Define an expected response. The values are based off `Swagger <https://swagger.io/specification>`_. """ def inner(o): value = Response(status, description, resour...
python
{ "resource": "" }
q48770
produces
train
def produces(*content_types): """ Define content types produced by an endpoint. """ def inner(o): if not all(isinstance(content_type, _compat.string_types) for content_type in content_types): raise ValueError("In parameter not a valid value.") try: getattr(o, 'pro...
python
{ "resource": "" }
q48771
Authorization.get_resource_id
train
def get_resource_id(self): """Gets the ``resource _id`` for this authorization. return: (osid.id.Id) - the ``Resource Id`` raise: IllegalState - ``has_resource()`` is ``false`` *compliance: mandatory -- This method must be implemented.* """ # Implemented from template ...
python
{ "resource": "" }
q48772
Authorization.get_resource
train
def get_resource(self): """Gets the ``Resource`` for this authorization. return: (osid.resource.Resource) - the ``Resource`` raise: IllegalState - ``has_resource()`` is ``false`` raise: OperationFailed - unable to complete request *compliance: mandatory -- This method must be ...
python
{ "resource": "" }
q48773
Authorization.get_trust_id
train
def get_trust_id(self): """Gets the ``Trust`` ``Id`` for this authorization. return: (osid.id.Id) - the trust ``Id`` raise: IllegalState - ``has_trust()`` is ``false`` *compliance: mandatory -- This method must be implemented.* """ # Implemented from template for osid...
python
{ "resource": "" }
q48774
Authorization.get_trust
train
def get_trust(self): """Gets the ``Trust`` for this authorization. return: (osid.authentication.process.Trust) - the ``Trust`` raise: IllegalState - ``has_trust()`` is ``false`` raise: OperationFailed - unable to complete request *compliance: mandatory -- This method must be i...
python
{ "resource": "" }
q48775
Authorization.get_function_id
train
def get_function_id(self): """Gets the ``Function Id`` for this authorization. return: (osid.id.Id) - the function ``Id`` *compliance: mandatory -- This method must be implemented.* """ # Implemented from template for osid.learning.Activity.get_objective_id if not bool(...
python
{ "resource": "" }
q48776
Authorization.get_function
train
def get_function(self): """Gets the ``Function`` for this authorization. return: (osid.authorization.Function) - the function raise: OperationFailed - unable to complete request *compliance: mandatory -- This method must be implemented.* """ # Implemented from template...
python
{ "resource": "" }
q48777
Authorization.get_qualifier_id
train
def get_qualifier_id(self): """Gets the ``Qualifier Id`` for this authorization. return: (osid.id.Id) - the qualifier ``Id`` *compliance: mandatory -- This method must be implemented.* """ # Implemented from template for osid.learning.Activity.get_objective_id if not bo...
python
{ "resource": "" }
q48778
Authorization.get_qualifier
train
def get_qualifier(self): """Gets the qualifier for this authorization. return: (osid.authorization.Qualifier) - the qualifier raise: OperationFailed - unable to complete request *compliance: mandatory -- This method must be implemented.* """ # Implemented from template...
python
{ "resource": "" }
q48779
VaultNode.get_vault
train
def get_vault(self): """Gets the ``Vault`` at this node. return: (osid.authorization.Vault) - the vault represented by this node *compliance: mandatory -- This method must be implemented.* """ if self._lookup_session is None: mgr = get_provider_manag...
python
{ "resource": "" }
q48780
VaultNode.get_parent_vault_nodes
train
def get_parent_vault_nodes(self): """Gets the parents of this vault. return: (osid.authorization.VaultNodeList) - the parents of this vault *compliance: mandatory -- This method must be implemented.* """ parent_vault_nodes = [] for node in self._my_map['...
python
{ "resource": "" }
q48781
random_flip
train
def random_flip(sequence,rnum=None): """Flip a sequence direction with 0.5 probability""" randin = rnum if not randin: randin = RandomSource() if randin.random() < 0.5: return rc(sequence) return sequence
python
{ "resource": "" }
q48782
ErrorMaker.random_insertion
train
def random_insertion(self,fastq,rate,max_inserts=1): """Perform the permutation on the sequence. If authorized to do multiple bases they are done at hte rate defined here. :param fastq: FASTQ sequence to permute :type fastq: format.fastq.FASTQ :param rate: how frequently to permute :type rate: floa...
python
{ "resource": "" }
q48783
CutMaker.set_custom
train
def set_custom(self,gmin,gmu,gsigma): """Set a minimum lengtha, and then the gaussian distribution parameters for cutting For any sequence longer than the minimum the guassian parameters will be used""" self._gauss_min = gmin self._gauss_mu = gmu self._gauss_sigma = gsigma
python
{ "resource": "" }
q48784
DragAndDropItemRecord._is_match
train
def _is_match(self, response, answer): """Does the response match the answer """ def compare_conditions(droppable_id, spatial_units, response_conditions): """Compare response coordinates with spatial units for droppable_id""" coordinate_match = True for coordinate in...
python
{ "resource": "" }
q48785
DragAndDropItemRecord.get_correctness_for_response
train
def get_correctness_for_response(self, response): """get measure of correctness available for a particular response""" for answer in self.my_osid_object.get_answers(): if self._is_match(response, answer): try: return answer.get_score() exce...
python
{ "resource": "" }
q48786
MultiLanguageDragAndDropQuestionRecord._update_object_map
train
def _update_object_map(self, obj_map): """unclear if it's better to use this method or get_object_map My main consideration is that MultiLanguageQuestionRecord already overrides get_object_map """ obj_map['droppables'] = self.get_droppables() obj_map['targets'] = self.get...
python
{ "resource": "" }
q48787
MultiLanguageDragAndDropQuestionFormRecord.remove_droppable
train
def remove_droppable(self, droppable_id): """remove a droppable, given the id""" updated_droppables = [] for droppable in self.my_osid_object_form._my_map['droppables']: if droppable['id'] != droppable_id: updated_droppables.append(droppable) self.my_osid_obje...
python
{ "resource": "" }
q48788
MultiLanguageDragAndDropQuestionFormRecord.remove_target
train
def remove_target(self, target_id): """remove a target, given the id""" updated_targets = [] for target in self.my_osid_object_form._my_map['targets']: if target['id'] != target_id: updated_targets.append(target) self.my_osid_object_form._my_map['targets'] = u...
python
{ "resource": "" }
q48789
MultiLanguageDragAndDropQuestionFormRecord.add_zone
train
def add_zone(self, spatial_unit, container_id, name='', description='', visible=True, reuse=0, drop_behavior_type=None): """container_id is a targetId that the zone belongs to """ if not isinstance(spatial_unit, abc_mapping_primitives.SpatialUnit): raise InvalidArgument('zone is not ...
python
{ "resource": "" }
q48790
MultiLanguageDragAndDropQuestionFormRecord.remove_zone
train
def remove_zone(self, zone_id): """remove a zone, given the id""" updated_zones = [] for zone in self.my_osid_object_form._my_map['zones']: if zone['id'] != zone_id: updated_zones.append(zone) self.my_osid_object_form._my_map['zones'] = updated_zones
python
{ "resource": "" }
q48791
LearningManager.get_objective_search_session
train
def get_objective_search_session(self): """Gets the OsidSession associated with the objective search service. return: (osid.learning.ObjectiveSearchSession) - an ObjectiveSearchSession raise: OperationFailed - unable to complete request raise: Unimplemented - s...
python
{ "resource": "" }
q48792
LearningManager.get_objective_search_session_for_objective_bank
train
def get_objective_search_session_for_objective_bank(self, objective_bank_id=None): """Gets the OsidSession associated with the objective search service for the given objective bank. arg: objectiveBankId (osid.id.Id): the Id of the objective bank return: (osid.learning...
python
{ "resource": "" }
q48793
LearningManager.get_activity_search_session
train
def get_activity_search_session(self): """Gets the OsidSession associated with the activity search service. return: (osid.learning.ActivitySearchSession) - a ActivitySearchSession raise: OperationFailed - unable to complete request raise: Unimplemented - suppor...
python
{ "resource": "" }
q48794
LearningManager.get_activity_search_session_for_objective_bank
train
def get_activity_search_session_for_objective_bank(self, objective_bank_id=None): """Gets the OsidSession associated with the activity search service for the given objective bank. arg: objectiveBankId (osid.id.Id): the Id of the objective bank return: (osid.learning.A...
python
{ "resource": "" }
q48795
LearningManager.get_learning_path_session
train
def get_learning_path_session(self): """Gets the OsidSession associated with the learning path service. return: (osid.learning.LearningPathSession) - a LearningPathSession raise: OperationFailed - unable to complete request raise: Unimplemented - supports_learning_path...
python
{ "resource": "" }
q48796
LearningManager.get_learning_path_session_for_objective_bank
train
def get_learning_path_session_for_objective_bank(self, objective_bank_id=None): """Gets the OsidSession associated with the learning path service for the given objective bank. arg: objectiveBankId (osid.id.Id): the Id of the ObjectiveBank return: (osid.learning.Learni...
python
{ "resource": "" }
q48797
LearningProxyManager.get_proficiency_search_session
train
def get_proficiency_search_session(self, proxy): """Gets the ``OsidSession`` associated with the proficiency search service. :param proxy: a proxy :type proxy: ``osid.proxy.Proxy`` :return: a ``ProficiencySearchSession`` :rtype: ``osid.learning.ProficiencySearchSession`` ...
python
{ "resource": "" }
q48798
LearningProxyManager.get_proficiency_search_session_for_objective_bank
train
def get_proficiency_search_session_for_objective_bank(self, objective_bank_id, proxy): """Gets the ``OsidSession`` associated with the proficiency search service for the given objective bank. :param objective_bank_id: the ``Id`` of the ``ObjectiveBank`` :type objective_bank_id: ``osid.id.Id`` ...
python
{ "resource": "" }
q48799
LearningProxyManager.get_my_learning_path_session
train
def get_my_learning_path_session(self, proxy): """Gets the ``OsidSession`` associated with the my learning path service. :param proxy: a proxy :type proxy: ``osid.proxy.Proxy`` :return: a ``MyLearningPathSession`` :rtype: ``osid.learning.MyLearningPathSession`` :raise: `...
python
{ "resource": "" }