def merge(self, other): """ Merge another set of simulation specs into this one. @param other: Simulation specs @type other: lems.model.simulation.Simulation """ merge_dict(self.runs, other.runs) merge_dict(self.records, other.records) merge_dict(self.data_displays, other.data_displays) merge_dict(self.data_writers, other.data_writers)
def merge_from_type(self, other, context): """ Merge another set of structural characteristics into this one. @param other: Structural characteristics @type other: lems.model.structure.Structure @param context: Context of the component @type context: lems.model.context.Context """ self.event_connections += other.event_connections for c in other.single_child_defs: if c in context.component_refs: self.add_single_child_def(c) else: raise ModelError("Trying to multi-instantiate from an " "invalid component reference '{0}'".format(\ c)) for c in other.multi_child_defs: n = other.multi_child_defs[c] if c in context.component_refs: component = context.component_refs[c] if n in context.parameters: number = int(context.parameters[n].numeric_value) self.add_multi_child_def(component, number) else: raise ModelError("Trying to multi-instantiate using an " "invalid number parameter '{0}'".\ format(n)) else: raise ModelError("Trying to multi-instantiate from an " "invalid component reference '{0}'".format(\ c)) self.foreach += other.foreach merge_dict(self.foreach_mappings, other.foreach_mappings) merge_dict(self.with_mappings, other.with_mappings)
def merge(self, regime): """ Merge another regime into this one. @param regime: Regime to be merged in. @type regime: lems.model.dynamics.Regime """ merge_dict(self.state_variables, regime) merge_dict(self.time_derivatives, regime.time_derivatives) merge_dict(self.derived_variables, regime.derived_variables) self.event_handlers += regime.event_handlers merge_dict(self.kinetic_schemes, regime.kinetic_schemes)
def merge(self, other): """ Merge another set of structural characteristics into this one. @param other: structural characteristics @type other: lems.model.structure.Structure """ self.event_connections += other.event_connections self.single_child_defs += other.single_child_defs merge_dict(self.multi_child_defs, other.multi_child_defs) self.foreach += other.foreach merge_dict(self.foreach_mappings, other.foreach_mappings) merge_dict(self.with_mappings, other.with_mappings)
def merge(self, other, model): """ Merge another context (base or type context) into this one. @param other: Base or type context to be merged in @type other: lems.model.context.Context """ merge_dict(self.component_types, other.component_types) merge_ordered_dict(self.components, self.components_ordering, other.components, other.components_ordering) merge_dict(self.component_refs, other.component_refs) merge_dict(self.child_defs, other.child_defs) merge_dict(self.children_defs, other.children_defs) for child in other.children: self.children.append(child) if (self.context_type == other.context_type and self.context_type in [Context.COMPONENT_TYPE, Context.COMPONENT]): self.merge_extended_parameters(other) elif (self.context_type == Context.COMPONENT and other.context_type == Context.COMPONENT_TYPE): self.merge_component_parameters_from_component_type(other, model) merge_dict(self.dynamics_profiles, other.dynamics_profiles) if not self.selected_dynamics_profile: self.selected_dynamics_profile = other.selected_dynamics_profile self.exposures |= other.exposures merge_dict(self.requirements, other.requirements) merge_dict(self.texts, other.texts) merge_dict(self.paths, other.paths) merge_dict(self.links, other.links) self.event_in_ports |= other.event_in_ports self.event_out_ports |= other.event_out_ports if (self.context_type == Context.COMPONENT and other.context_type == Context.COMPONENT_TYPE): self.structure.merge_from_type(other.structure, self) else: self.structure.merge(other.structure) self.simulation.merge(other.simulation) merge_dict(self.attachments, other.attachments)