def to_xml(self): positions = [self.positions.to_xml()] if self.positions else [] return E(self.element_name, E.Number(str(self.number)), E.Cell(self.cell.to_xml()), *positions, name=self.name)
def to_xml(self): element = E(self.element_name) if self._positions: for pos in self._positions: x, y, z = pos element.append( E.position(x=str(x), y=str(y), z=str(z), units="um")) elif self.structure: element.append(E.structure(self.structure.name)) else: raise Exception("Neither positions nor structure is set.") return element
def to_xml(self): element = E(self.element_name) if self._positions: for pos in self._positions: x, y, z = pos element.append(E.position(x=str(x), y=str(y), z=str(z), units="um")) elif self.structure: element.append(E.structure(self.structure.name)) else: raise Exception("Neither positions nor structure is set.") return element
def to_xml(self): def item_to_xml(item): if isinstance(item, Reference): return item.to_xml() else: return E.Reference(item.name) return E( self.element_name, *[ E.Item(item_to_xml(item), index=str(i)) for i, item in enumerate(self.items) ])
def to_xml(self): return E(self.element_name, name=self.name, *[ p.to_xml() for p in chain(self.populations.values( ), self.selections.values(), self.projections.values()) ])
def to_xml(self): self.standardize_units() return E( self.element_name, *[ c.to_xml(as_reference=False) if isinstance( c, nineml.user_layer.BaseULObject) else c.to_xml() for c in self.itervalues() ])
def to_xml(self): kwargs = { 'symbol': self.name, 'dimension': self.dimension.name, 'power': str(self.power) } if self.offset: kwargs['offset'] = str(self.offset) return E(self.element_name, **kwargs)
def visit_componentclass(self, componentclass): elements = ([p.accept_visitor(self) for p in componentclass.analog_ports] + [p.accept_visitor(self) for p in componentclass.event_ports] + [p.accept_visitor(self) for p in componentclass.parameters] + [componentclass.dynamicsblock.accept_visitor(self)]) return E('ComponentClass', *elements, name=componentclass.name)
def write(self, file): # @ReservedAssignment self.standardize_units() xml = [self.to_xml()] xml.extend( chain(*((u.to_xml(), u.dimension.to_xml()) for u in self.used_units))) doc = E.NineML(*xml, xmlns=nineml_namespace) etree.ElementTree(doc).write(file, encoding="UTF-8", pretty_print=True, xml_declaration=True)
def to_xml(self): """ docstring missing, although since the decorators don't preserve the docstring, it doesn't matter at the moment. """ props_and_initial_values = ( self._properties.to_xml() + [iv.to_xml() for iv in self.initial_values.values()]) element = E(self.element_name, self._definition.to_xml(), *props_and_initial_values, name=self.name) return element
def to_xml(self): pcs = defaultdict(list) for pc in self.port_connections: pcs[pc._receive_role].append( E('From' + pc._send_role.capitalize(), send_port=pc.send_port, receive_port=pc.receive_port)) args = [ E.Source(self.source.to_xml(), *pcs['source']), E.Destination(self.destination.to_xml(), *pcs['destination']), E.Connectivity(self.connectivity.to_xml()), E.Response(self.response.to_xml(), *pcs['response']) ] if self.plasticity: args.append( E.Plasticity(self.plasticity.to_xml(), *pcs['plasticity'])) args.append(self.delay.to_xml()) return E(self.element_name, *args, name=self.name)
def visit_eventreceiveport(self, port): return E('EventReceivePort', name=port.name)
def to_xml(self): kwargs = {'name': self.name} kwargs.update(dict((k, str(v)) for k, v in self._dims.items())) return E(self.element_name, **kwargs)
def to_xml(self): return E(self.element_name, *self.itervalues())
def visit_alias(self, alias): return E('Alias', E("MathInline", alias.rhs), name=alias.lhs)
def visit_analogreceiveport(self, port): return E('AnalogReceivePort', name=port.name, dimension=port.dimension.name)
def visit_onevent(self, on_event): elements = ([p.accept_visitor(self) for p in on_event.state_assignments] + [p.accept_visitor(self) for p in on_event.event_outputs]) return E('OnEvent', *elements, port=on_event.src_port_name, target_regime=on_event.target_regime.name)
def visit_parameter(self, parameter): return E('Parameter', name=parameter.name, dimension=parameter.dimension.name)
def visit_analogreduceport(self, port): return E('AnalogReducePort', name=port.name, dimension=port.dimension.name, operator=port.reduce_op)
def visit_trigger(self, trigger): return E('Trigger', E("MathInline", trigger.rhs))
def to_xml(self): return E(self.element_name, str(self.value))
def to_xml(self): return E(self.element_name, self.value, index=self.index)
def item_to_xml(item): if isinstance(item, Reference): return item.to_xml() else: return E.Reference(item.name)
def visit_eventsendport(self, port): return E('EventSendPort', name=port.name)
def visit_analogsendport(self, port): return E('AnalogSendPort', name=port.name, dimension=port.dimension.name)
def to_xml(self): return E(self.element_name, self.operation.to_xml(), name=self.name)
def visit_assignment(self, assignment): return E('StateAssignment', E("MathInline", assignment.rhs), variable=assignment.lhs)
def to_xml(self): return E(self.element_name, url=self.url, mimetype=self.mimetype, columnName=self.columnName)
def visit_timederivative(self, time_derivative): return E('TimeDerivative', E("MathInline", time_derivative.rhs), variable=time_derivative.dependent_variable)
def to_xml(self): return E(self.element_name, *[r.to_xml() for r in self.rows])
def visit_oncondition(self, on_condition): nodes = chain(on_condition.state_assignments, on_condition.event_outputs, [on_condition.trigger]) newNodes = [n.accept_visitor(self) for n in nodes] return E('OnCondition', *newNodes, target_regime=on_condition._target_regime.name)