code
stringlengths
1
18.2k
'dt:date:rare_6', ] else: if text[1] == '.' or text[2] == '.': basekeys = ['dt:date:date_2', 'dt:date:date_4', 'dt:date:date_rus3', 'dt:date:date_4_point', 'dt:date:date_eng1', 'dt:date:noyear_1', 'dt:date:rare_2', 'dt:date:rare_3', ] basekeys += ['dt:date:de_base', 'dt:date:de_base_lc'] elif text[1] == ',' or text[2] ...
dates basekeys += ['dt:date:pt_base_article', 'dt:date:pt_base_lc_article', 'dt:date:pt_base', 'dt:date:pt_base_lc'] # Adding german dates basekeys += ['dt:date:de_base', 'dt:date:de_base_lc'] # Adding bulgarian dates basekeys += ['dt:date:bg_base', 'dt:date:bg_base_lc'] # Adding spanish dates basekeys += ['dt:date:es_...
def _get_catalog_hierarchy_id(self, catalog_id, proxy, runtime): """Gets the catalog hierarchy""" seed_str = convert_catalog_id_to_object_id_string(catalog_id) ident = Id(authority=self._authority, namespace='hierarchy.Hierarchy', identifier=seed_str) return HierarchyLookupSession(proxy, runtime).get_hierarchy(ident).g...
def _create_catalog_hierarchy(self, catalog_id, proxy, runtime): """Creates a catalog hierarchy""" seed_str = convert_catalog_id_to_object_id_string(catalog_id) has = HierarchyAdminSession(proxy, runtime) hfc = has.get_hierarchy_form_for_create([]) hfc.set_display_name(catalog_id.get_identifier().title() + ' Hierarchy'...
def _set_relationship_type(self, type_identifier, display_name=None, display_label=None, description=None, domain='Relationship'): """Sets the relationship type""" if display_name is None: display_name = type_identifier if display_label is None: display_label = display_name if description is None: description = 'Relati...
def get_roots(self): """Gets the root nodes of this hierarchy. return: (osid.id.IdList) - the root nodes raise: OperationFailed - unable to complete request raise: PermissionDenied - authorization failure *compliance: mandatory -- This method must be implemented.* """ id_list = [] for r in self._rls.get_relationships_b...
def is_parent(self, id_, parent_id): """Tests if an ``Id`` is a direct parent of another. arg: id (osid.id.Id): the ``Id`` to query arg: parent_id (osid.id.Id): the ``Id`` of a parent return: (boolean) - ``true`` if this ``parent_id`` is a parent of ``id,`` ``false`` otherwise raise: NotFound - ``id`` is not found rais...
def get_parents(self, id_): """Gets the parents of the given ``id``. arg: id (osid.id.Id): the ``Id`` to query return: (osid.id.IdList) - the parents of the ``id`` raise: NotFound - ``id`` is not found raise: NullArgument - ``id`` is ``null`` raise: OperationFailed - unable to complete request raise: PermissionDenied -...
def is_child(self, id_, child_id): """Tests if a node is a direct child of another. arg: id (osid.id.Id): the ``Id`` to query arg: child_id (osid.id.Id): the ``Id`` of a child return: (boolean) - ``true`` if this ``child_id`` is a child of the ``Id,`` ``false`` otherwise raise: NotFound - ``id`` is not found raise: Nul...
def get_children(self, id_): """Gets the children of the given ``Id``. arg: id (osid.id.Id): the ``Id`` to query return: (osid.id.IdList) - the children of the ``id`` raise: NotFound - ``id`` is not found raise: NullArgument - ``id`` is ``null`` raise: OperationFailed - unable to complete request raise: PermissionDenie...
def get_nodes(self, id_, ancestor_levels=10, descendant_levels=10, include_siblings=False): """Gets a portion of the hierarchy for the given ``Id``. arg: id (osid.id.Id): the ``Id`` to query arg: ancestor_levels (cardinal): the maximum number of ancestor levels to include. A value of 0 returns no parents in the node. a...
include_siblings = bool(include_siblings) parent_node_list = [] child_node_list = [] if ancestor_levels != 0: for parent_id in self.get_parents(id_): parent_node_list.append(self.get_nodes(parent_id, ancestor_levels - 1, 0)) if descendant_levels != 0: for child_id in self.get_children(id_): child_node_list.append(self....
def add_root(self, id_): """Adds a root node. arg: id (osid.id.Id): the ``Id`` of the node raise: AlreadyExists - ``id`` is already in hierarchy raise: NotFound - ``id`` not found raise: NullArgument - ``id`` is ``null`` raise: OperationFailed - unable to complete request raise: PermissionDenied - authorization failure...
def add_child(self, id_, child_id): """Adds a child to a ``Id``. arg: id (osid.id.Id): the ``Id`` of the node arg: child_id (osid.id.Id): the ``Id`` of the new child raise: AlreadyExists - ``child_id`` is already a child of ``id`` raise: NotFound - ``id`` or ``child_id`` not found raise: NullArgument - ``id`` or ``chil...
def remove_root(self, id_): """Removes a root node. arg: id (osid.id.Id): the ``Id`` of the node raise: NotFound - ``id`` was not found or not in hierarchy raise: NullArgument - ``id`` is ``null`` raise: OperationFailed - unable to complete request raise: PermissionDenied - authorization failure *compliance: mandatory ...
def remove_child(self, id_, child_id): """Removes a childfrom an ``Id``. arg: id (osid.id.Id): the ``Id`` of the node arg: child_id (osid.id.Id): the ``Id`` of the child to remove raise: NotFound - ``id`` or ``child_id`` was not found or ``child_id`` is not a child of ``id`` raise: NullArgument - ``id`` or ``child_id``...
def remove_children(self, id_): """Removes all childrenfrom an ``Id``. arg: id (osid.id.Id): the ``Id`` of the node raise: NotFound - an node identified by the given ``Id`` was not found raise: NullArgument - ``id`` is ``null`` raise: OperationFailed - unable to complete request raise: PermissionDenied - authorization ...
def _adopt_orphans(self, negligent_parent_id): """Clean up orphaned children""" for child_id in self._hts.get_children(negligent_parent_id): self.remove_child(negligent_parent_id, child_id) if not self._hts.has_parents(child_id): self._assign_as_root(child_id)
def _assign_as_root(self, id_): """Assign an id_ a root object in the hierarchy""" rfc = self._ras.get_relationship_form_for_create(self._phantom_root_id, id_, []) rfc.set_display_name('Implicit Root to ' + str(id_) + ' Parent-Child Relationship') rfc.set_description(self._relationship_type.get_display_name().get_text(...
def can_create_hierarchy_with_record_types(self, hierarchy_record_types): """Tests if this user can create a single ``Hierarchy`` using the desired record types. While ``HierarchyManager.getHierarchyRecordTypes()`` can be used to examine which records are supported, this method tests which record(s) are required for cr...
return self._catalog_session.can_create_catalog_with_record_types(catalog_record_types=hierarchy_record_types) return True
def update_hierarchy(self, hierarchy_form): """Updates an existing hierarchy. arg: hierarchy_form (osid.hierarchy.HierarchyForm): the form containing the elements to be updated raise: IllegalState - ``hierarchy_form`` already used in an update transaction raise: InvalidArgument - the form contains an invalid value rais...
update transaction') except KeyError: raise errors.Unsupported('hierarchy_form did not originate from this session') if not hierarchy_form.is_valid(): raise errors.InvalidArgument('one or more of the form elements is invalid') collection.save(hierarchy_form._my_map) # save is deprecated - change to replace_one self._fo...
def delete_hierarchy(self, hierarchy_id): """Deletes a ``Hierarchy``. arg: hierarchy_id (osid.id.Id): the ``Id`` of the ``Hierarchy`` to remove raise: NotFound - ``hierarchy_id`` not found raise: NullArgument - ``hierarchy_id`` is ``null`` raise: OperationFailed - unable to complete request raise: PermissionDenied - au...
def alias_hierarchy(self, hierarchy_id, alias_id): """Adds an ``Id`` to a ``Hierarchy`` for the purpose of creating compatibility. The primary ``Id`` of the ``Hierarchy`` is determined by the provider. The new ``Id`` performs as an alias to the primary ``Id``. If the alias is a pointer to another vault it is reassigned...
def _set_bank_view(self, session): """Sets the underlying bank view to match current view""" if self._bank_view == COMPARATIVE: try: session.use_comparative_bank_view() except AttributeError: pass else: try: session.use_plenary_bank_view() except AttributeError: pass
def use_plenary_bank_view(self): """Pass through to provider ItemBankSession.use_plenary_bank_view""" self._bank_view = PLENARY # self._get_provider_session('item_bank_session') # To make sure the session is tracked for session in self._get_provider_sessions(): try: session.use_plenary_bank_view() except AttributeError...
def get_banks_by_item(self, *args, **kwargs): """Pass through to provider ItemBankSession.get_banks_by_item""" # Implemented from kitosid template for - # osid.resource.ResourceBinSession.get_bins_by_resource catalogs = self._get_provider_session('item_bank_session').get_banks_by_item(*args, **kwargs) cat_list = [] for...
def get_bank(self, *args, **kwargs): """Pass through to provider BankLookupSession.get_bank""" # Implemented from kitosid template for - # osid.resource.BinLookupSession.get_bin return Bank( self._provider_manager, self._get_provider_session('bank_lookup_session').get_bank(*args, **kwargs), self._runtime, self._proxy)
def get_banks(self): """Pass through to provider BankLookupSession.get_banks""" # Implemented from kitosid template for - # osid.resource.BinLookupSession.get_bins_template catalogs = self._get_provider_session('bank_lookup_session').get_banks() cat_list = [] for cat in catalogs: cat_list.append(Bank(self._provider_man...
def get_bank_form(self, *args, **kwargs): """Pass through to provider BankAdminSession.get_bank_form_for_update""" # Implemented from kitosid template for - # osid.resource.BinAdminSession.get_bin_form_for_update_template # This method might be a bit sketchy. Time will tell. if isinstance(args[-1], list) or 'bank_recor...
def save_bank(self, bank_form, *args, **kwargs): """Pass through to provider BankAdminSession.update_bank""" # Implemented from kitosid template for - # osid.resource.BinAdminSession.update_bin if bank_form.is_for_update(): return self.update_bank(bank_form, *args, **kwargs) else: return self.create_bank(bank_form, *ar...
def use_comparative_assessment_part_bank_view(self): """Pass through to provider AssessmentPartBankSession.use_comparative_assessment_part_bank_view""" self._bank_view = COMPARATIVE # self._get_provider_session('assessment_part_bank_session') # To make sure the session is tracked for session in self._get_provider_sessi...
def _set_bank_view(self, session): """Sets the underlying bank view to match current view""" if self._bank_view == FEDERATED: try: session.use_federated_bank_view() except AttributeError: pass else: try: session.use_isolated_bank_view() except AttributeError: pass
def _get_sub_package_provider_session(self, sub_package, session_name, proxy=None): """Gets the session from a sub-package""" agent_key = self._get_agent_key() if session_name in self._provider_sessions[agent_key]: return self._provider_sessions[agent_key][session_name] else: manager = self._get_sub_package_provider_ma...
def use_comparative_item_view(self): """Pass through to provider ItemLookupSession.use_comparative_item_view""" self._object_views['item'] = COMPARATIVE # self._get_provider_session('item_lookup_session') # To make sure the session is tracked for session in self._get_provider_sessions(): try: session.use_comparative_it...
def use_plenary_item_view(self): """Pass through to provider ItemLookupSession.use_plenary_item_view""" self._object_views['item'] = PLENARY # self._get_provider_session('item_lookup_session') # To make sure the session is tracked for session in self._get_provider_sessions(): try: session.use_plenary_item_view() except...
def use_federated_bank_view(self): """Pass through to provider ItemLookupSession.use_federated_bank_view""" self._bank_view = FEDERATED # self._get_provider_session('item_lookup_session') # To make sure the session is tracked for session in self._get_provider_sessions(): try: session.use_federated_bank_view() except At...
def use_isolated_bank_view(self): """Pass through to provider ItemLookupSession.use_isolated_bank_view""" self._bank_view = ISOLATED # self._get_provider_session('item_lookup_session') # To make sure the session is tracked for session in self._get_provider_sessions(): try: session.use_isolated_bank_view() except Attrib...
def get_item_form(self, *args, **kwargs): """Pass through to provider ItemAdminSession.get_item_form_for_update""" # Implemented from kitosid template for - # osid.resource.ResourceAdminSession.get_resource_form_for_update # This method might be a bit sketchy. Time will tell. if isinstance(args[-1], list) or 'item_reco...
def save_item(self, item_form, *args, **kwargs): """Pass through to provider ItemAdminSession.update_item""" # Implemented from kitosid template for - # osid.resource.ResourceAdminSession.update_resource if item_form.is_for_update(): return self.update_item(item_form, *args, **kwargs) else: return self.create_item(item...
def use_comparative_assessment_view(self): """Pass through to provider AssessmentLookupSession.use_comparative_assessment_view""" self._object_views['assessment'] = COMPARATIVE # self._get_provider_session('assessment_lookup_session') # To make sure the session is tracked for session in self._get_provider_sessions(): t...
def use_plenary_assessment_view(self): """Pass through to provider AssessmentLookupSession.use_plenary_assessment_view""" self._object_views['assessment'] = PLENARY # self._get_provider_session('assessment_lookup_session') # To make sure the session is tracked for session in self._get_provider_sessions(): try: session....
def get_assessment_form(self, *args, **kwargs): """Pass through to provider AssessmentAdminSession.get_assessment_form_for_update""" # Implemented from kitosid template for - # osid.resource.ResourceAdminSession.get_resource_form_for_update # This method might be a bit sketchy. Time will tell. if isinstance(args[-1], l...
def save_assessment(self, assessment_form, *args, **kwargs): """Pass through to provider AssessmentAdminSession.update_assessment""" # Implemented from kitosid template for - # osid.resource.ResourceAdminSession.update_resource if assessment_form.is_for_update(): return self.update_assessment(assessment_form, *args, **...
def add_item(self, *args, **kwargs): """Pass through to provider methods.""" try: self._get_provider_session('assessment_basic_authoring_session').add_item(*args, **kwargs) except InvalidArgument: self._get_sub_package_provider_session( 'assessment_authoring', 'assessment_part_item_design_session').add_item(*args, **kw...
def remove_item(self, *args, **kwargs): """Pass through to provider methods.""" try: self._get_provider_session('assessment_basic_authoring_session').remove_item(*args, **kwargs) except InvalidArgument: self._get_sub_package_provider_session( 'assessment_authoring', 'assessment_part_item_design_session').remove_item(*a...
def order_items(self, *args, **kwargs): """Pass through to provider methods.""" try: self._get_provider_session('assessment_basic_authoring_session').order_items(*args, **kwargs) except InvalidArgument: self._get_sub_package_provider_session( 'assessment_authoring', 'assessment_part_item_design_session').order_items(*a...
def use_comparative_assessment_offered_view(self): """Pass through to provider AssessmentOfferedLookupSession.use_comparative_assessment_offered_view""" self._object_views['assessment_offered'] = COMPARATIVE # self._get_provider_session('assessment_offered_lookup_session') # To make sure the session is tracked for sess...
def use_plenary_assessment_offered_view(self): """Pass through to provider AssessmentOfferedLookupSession.use_plenary_assessment_offered_view""" self._object_views['assessment_offered'] = PLENARY # self._get_provider_session('assessment_offered_lookup_session') # To make sure the session is tracked for session in self....
def get_assessment_offered_form(self, *args, **kwargs): """Pass through to provider AssessmentOfferedAdminSession.get_assessment_offered_form_for_update""" # Implemented from kitosid template for - # osid.resource.ResourceAdminSession.get_resource_form_for_update # This method might be a bit sketchy. Time will tell. if...
def save_assessment_offered(self, assessment_offered_form, *args, **kwargs): """Pass through to provider AssessmentOfferedAdminSession.update_assessment_offered""" # Implemented from kitosid template for - # osid.resource.ResourceAdminSession.update_resource if assessment_offered_form.is_for_update(): return self.updat...
def use_comparative_assessment_taken_view(self): """Pass through to provider AssessmentTakenLookupSession.use_comparative_assessment_taken_view""" self._object_views['assessment_taken'] = COMPARATIVE # self._get_provider_session('assessment_taken_lookup_session') # To make sure the session is tracked for session in sel...
def use_plenary_assessment_taken_view(self): """Pass through to provider AssessmentTakenLookupSession.use_plenary_assessment_taken_view""" self._object_views['assessment_taken'] = PLENARY # self._get_provider_session('assessment_taken_lookup_session') # To make sure the session is tracked for session in self._get_provi...
def get_assessment_taken_form(self, *args, **kwargs): """Pass through to provider AssessmentTakenAdminSession.get_assessment_taken_form_for_update""" # Implemented from kitosid template for - # osid.resource.ResourceAdminSession.get_resource_form_for_update # This method might be a bit sketchy. Time will tell. if isins...
def save_assessment_taken(self, assessment_taken_form, *args, **kwargs): """Pass through to provider AssessmentTakenAdminSession.update_assessment_taken""" # Implemented from kitosid template for - # osid.resource.ResourceAdminSession.update_resource if assessment_taken_form.is_for_update(): return self.update_assessme...
def use_comparative_assessment_part_view(self): """Pass through to provider AssessmentPartLookupSession.use_comparative_assessment_part_view""" self._object_views['assessment_part'] = COMPARATIVE # self._get_provider_session('assessment_part_lookup_session') # To make sure the session is tracked for session in self._ge...
def use_plenary_assessment_part_view(self): """Pass through to provider AssessmentPartLookupSession.use_plenary_assessment_part_view""" self._object_views['assessment_part'] = PLENARY # self._get_provider_session('assessment_part_lookup_session') # To make sure the session is tracked for session in self._get_provider_s...
def use_active_assessment_part_view(self): """Pass through to provider AssessmentPartLookupSession.use_active_assessment_part_view""" self._operable_views['assessment_part'] = ACTIVE # self._get_provider_session('assessment_part_lookup_session') # To make sure the session is tracked for session in self._get_provider_se...
def use_any_status_assessment_part_view(self): """Pass through to provider AssessmentPartLookupSession.use_any_status_assessment_part_view""" self._operable_views['assessment_part'] = ANY_STATUS # self._get_provider_session('assessment_part_lookup_session') # To make sure the session is tracked for session in self._get...
def use_sequestered_assessment_part_view(self): """Pass through to provider AssessmentPartLookupSession.use_sequestered_assessment_part_view""" # Does this need to be re-implemented to match the other non-sub-package view setters? self._containable_views['assessment_part'] = SEQUESTERED self._get_sub_package_provider_s...
def use_unsequestered_assessment_part_view(self): """Pass through to provider AssessmentPartLookupSession.use_unsequestered_assessment_part_view""" # Does this need to be re-implemented to match the other non-sub-package view setters? self._containable_views['assessment_part'] = UNSEQUESTERED self._get_sub_package_prov...
def get_assessment_part_form(self, *args, **kwargs): """Pass through to provider AssessmentPartAdminSession.get_assessment_part_form_for_update""" # This method might be a bit sketchy. Time will tell. if isinstance(args[-1], list) or 'assessment_part_record_types' in kwargs: return self.get_assessment_part_form_for_cre...
def save_assessment_part(self, assessment_part_form, *args, **kwargs): """Pass through to provider AssessmentPartAdminSession.update_assessment_part""" # Implemented from kitosid template for - # osid.resource.ResourceAdminSession.update_resource if assessment_part_form.is_for_update(): return self.update_assessment_pa...
def use_comparative_asseessment_part_item_view(self): """Pass through to provider AssessmentPartItemSession.use_comparative_asseessment_part_item_view""" self._object_views['asseessment_part_item'] = COMPARATIVE # self._get_provider_session('assessment_part_item_session') # To make sure the session is tracked for sessi...
def use_plenary_assessment_part_item_view(self): """Pass through to provider AssessmentPartItemSession.use_plenary_assessment_part_item_view""" self._object_views['assessment_part_item'] = PLENARY # self._get_provider_session('assessment_part_item_session') # To make sure the session is tracked for session in self._get...
def use_comparative_sequence_rule_view(self): """Pass through to provider SequenceRuleLookupSession.use_comparative_sequence_rule_view""" self._object_views['sequence_rule'] = COMPARATIVE # self._get_provider_session('sequence_rule_lookup_session') # To make sure the session is tracked for session in self._get_provider...
def use_plenary_sequence_rule_view(self): """Pass through to provider SequenceRuleLookupSession.use_plenary_sequence_rule_view""" self._object_views['sequence_rule'] = PLENARY # self._get_provider_session('sequence_rule_lookup_session') # To make sure the session is tracked for session in self._get_provider_sessions():...
def use_active_sequence_rule_view(self): """Pass through to provider SequenceRuleLookupSession.use_active_sequence_rule_view""" self._operable_views['sequence_rule'] = ACTIVE # self._get_provider_session('sequence_rule_lookup_session') # To make sure the session is tracked for session in self._get_provider_sessions(): ...
def use_any_status_sequence_rule_view(self): """Pass through to provider SequenceRuleLookupSession.use_any_status_sequence_rule_view""" self._operable_views['sequence_rule'] = ANY_STATUS # self._get_provider_session('sequence_rule_lookup_session') # To make sure the session is tracked for session in self._get_provider_...
def save_sequence_rule(self, sequence_rule_form, *args, **kwargs): """Pass through to provider SequenceRuleAdminSession.update_sequence_rule""" # Implemented from kitosid template for - # osid.resource.ResourceAdminSession.update_resource if sequence_rule_form.is_for_update(): return self.update_sequence_rule(sequence_...
def use_comparative_sequence_rule_enabler_view(self): """Pass through to provider SequenceRuleEnablerLookupSession.use_comparative_sequence_rule_enabler_view""" self._object_views['sequence_rule_enabler'] = COMPARATIVE # self._get_provider_session('sequence_rule_enabler_lookup_session') # To make sure the session is tr...
def use_plenary_sequence_rule_enabler_view(self): """Pass through to provider SequenceRuleEnablerLookupSession.use_plenary_sequence_rule_enabler_view""" self._object_views['sequence_rule_enabler'] = PLENARY # self._get_provider_session('sequence_rule_enabler_lookup_session') # To make sure the session is tracked for se...
def use_active_sequence_rule_enabler_view(self): """Pass through to provider SequenceRuleEnablerLookupSession.use_active_sequence_rule_enabler_view""" self._operable_views['sequence_rule_enabler'] = ACTIVE # self._get_provider_session('sequence_rule_enabler_lookup_session') # To make sure the session is tracked for ses...
def use_any_status_sequence_rule_enabler_view(self): """Pass through to provider SequenceRuleEnablerLookupSession.use_any_status_sequence_rule_enabler_view""" self._operable_views['sequence_rule_enabler'] = ANY_STATUS # self._get_provider_session('sequence_rule_enabler_lookup_session') # To make sure the session is tra...
def get_sequence_rule_enabler_form(self, *args, **kwargs): """Pass through to provider SequenceRuleEnablerAdminSession.get_sequence_rule_enabler_form_for_update""" # Implemented from kitosid template for - # osid.resource.ResourceAdminSession.get_resource_form_for_update # This method might be a bit sketchy. Time will ...
def save_sequence_rule_enabler(self, sequence_rule_enabler_form, *args, **kwargs): """Pass through to provider SequenceRuleEnablerAdminSession.update_sequence_rule_enabler""" # Implemented from kitosid template for - # osid.resource.ResourceAdminSession.update_resource if sequence_rule_enabler_form.is_for_update(): ret...
def use_comparative_sequence_rule_enabler_rule_view(self): """Pass through to provider SequenceRuleEnablerRuleLookupSession.use_comparative_sequence_rule_enabler_rule_view""" self._object_views['sequence_rule_enabler_rule'] = COMPARATIVE # self._get_provider_session('sequence_rule_enabler_rule_lookup_session') # To mak...
def use_plenary_sequence_rule_enabler_rule_view(self): """Pass through to provider SequenceRuleEnablerRuleLookupSession.use_plenary_sequence_rule_enabler_rule_view""" self._object_views['sequence_rule_enabler_rule'] = PLENARY # self._get_provider_session('sequence_rule_enabler_rule_lookup_session') # To make sure the s...
def _init_map(self): """stub""" self.my_osid_object_form._my_map['confusedLearningObjectiveIds'] = \ self._confused_learning_objectives_metadata['default_list_values'][0] self.my_osid_object_form._my_map['feedback'] = \ self._feedback_metadata['default_string_values'][0]
def _init_metadata(self): """stub""" self._min_string_length = None self._max_string_length = None self._confused_learning_objectives_metadata = { 'element_id': Id(self.my_osid_object_form._authority, self.my_osid_object_form._namespace, 'confusedLearningObjectiveIds'), 'element_label': 'Confused Learning Objectives', ...
def _init_metadata(self): """stub""" self._confused_learning_objectives_metadata = { 'element_id': Id(self.my_osid_object_form._authority, self.my_osid_object_form._namespace, 'confusedLearningObjectiveIds'), 'element_label': 'Confused Learning Objectives', 'instructions': 'List of IDs', 'required': False, 'read_only':...
def clear_feedbacks(self): """stub""" if self.get_feedbacks_metadata().is_read_only(): raise NoAccess() self.my_osid_object_form._my_map['feedbacks'] = \ self._feedbacks_metadata['default_object_values'][0]
def _extract_params_from_i0(only_variable_parameters, parameters_with_variability, initial_conditions_with_variability): """ Used within the distance/cost function to create the current kinetic parameter and initial condition vectors to be used during that interaction, using current values in i0. This function takes i0...
# If param not variable, add it from param list if not is_variable: complete_params.append(param) else: # Otherwise add it from variable parameters list complete_params.append(only_variable_parameters[counter]) counter += 1 complete_initial_conditions = [] for initial_condition, is_variable in initial_conditions_with_v...
def infer(self, number_of_processes=1, *args, **kwargs): """ :param number_of_processes: If set to more than 1, the inference routines will be paralellised using ``multiprocessing`` module :param args: arguments to pass to :meth:`Inference.infer` :param kwargs: keyword arguments to pass to :meth:`Inference.infer` :retu...
def _generate_values_with_variability_and_constraints(self, symbols, starting_values, variable_parameters): """ Generates the `values_with_variability` formatted list from the provided symbols, starting values and variable parameters :param symbols: The symbols defining each of the values in the starting values list :p...
constraint = variable_parameters[parameter] variable = True except KeyError: try: constraint = variable_parameters[str(parameter)] variable = True except KeyError: constraint = None variable = False values_with_variability.append((parameter_value, variable)) if variable: constraints.append(constraint) return values_wit...
def tmybasename(usaf): """Basename for USAF base. Args: usaf (str): USAF code Returns: (str) """ url_file = open(env.SRC_PATH + '/tmy3.csv') for line in url_file.readlines(): if line.find(usaf) is not -1: return line.rstrip().partition(',')[0]
def normalize_date(tmy_date, year): """change TMY3 date to an arbitrary year. Args: tmy_date (datetime): date to mangle. year (int): desired year. Returns: (None) """ month = tmy_date.month day = tmy_date.day - 1 hour = tmy_date.hour # hack to get around 24:00 notation if month is 1 and day is 0 and hour is 0: year = y...
def total(usaf, field='GHI (W/m^2)'): """total annual insolation, defaults to GHI.""" running_total = 0 usafdata = data(usaf) for record in usafdata: running_total += float(record[field]) return running_total/1000.
def next(self): """iterate.""" record = self.tmy_data.next() _sd = record['Date (MM/DD/YYYY)'] + ' ' + record['Time (HH:MM)'] record['utc_datetime'] = strptime(_sd, self.tz) record['datetime'] = strptime(_sd) return record
def get_proxy_session(self): """Gets a ``ProxySession`` which is responsible for acquiring authentication credentials on behalf of a service client. return: (osid.proxy.ProxySession) - a proxy session for this service raise: OperationFailed - unable to complete request raise: Unimplemented - ``supports_proxy()`` is ``f...
def initialize(self, runtime=None): """Initializes this manager. A manager is initialized once at the time of creation. arg: runtime (osid.OsidRuntimeManager): the runtime environment raise: CONFIGURATION_ERROR - an error with implementation configuration raise: ILLEGAL_STATE - this manager has already been initialized...
is not None: raise IllegalState() self._runtime = runtime config = runtime.get_configuration() parameter_id = Id('parameter:hostName@dlkit_service') host = config.get_value_by_parameter(parameter_id).get_string_value() if host is not None: self._host = host parameter_id = Id('parameter:appKey@dlkit_service') app_key = ...
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
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.rules: by_lhs[lhs].append((lhs, rhs)) for y in rhs: if y...
= Grammar() g.set_start(self.start) for [lhs], rhs in self.rules: if (lhs in reachable & productive and all(y not in self.nonterminals or y in reachable & productive for y in rhs)): g.add_rule([lhs], rhs) return g
def mea_approximation(model, max_order, closure='scalar', *closure_args, **closure_kwargs): r""" A wrapper around :class:`~means.approximation.mea.moment_expansion_approximation.MomentExpansionApproximation`. It performs moment expansion approximation (MEA) up to a given order of moment. See :class:`~means.approximatio...
def run(self): r""" Overrides the default run() method. Performs the complete analysis on the model specified during initialisation. :return: an ODE problem which can be further used in inference and simulation. :rtype: :class:`~means.core.problems.ODEProblem` """ max_order = self.__max_order stoichiometry_matrix = sel...