示例#1
0
 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)
示例#2
0
 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
示例#3
0
 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
示例#4
0
    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)
            ])
示例#5
0
 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())
              ])
示例#6
0
 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()
         ])
示例#7
0
 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)
示例#8
0
 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)
示例#9
0
 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)
示例#10
0
 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
示例#11
0
 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)
示例#12
0
 def visit_eventreceiveport(self, port):
     return E('EventReceivePort', name=port.name)
示例#13
0
 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)
示例#14
0
 def to_xml(self):
     return E(self.element_name, *self.itervalues())
示例#15
0
 def visit_alias(self, alias):
     return E('Alias', E("MathInline", alias.rhs), name=alias.lhs)
示例#16
0
 def visit_analogreceiveport(self, port):
     return E('AnalogReceivePort', name=port.name,
              dimension=port.dimension.name)
示例#17
0
 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)
示例#18
0
 def visit_parameter(self, parameter):
     return E('Parameter',
              name=parameter.name,
              dimension=parameter.dimension.name)
示例#19
0
 def visit_analogreduceport(self, port):
     return E('AnalogReducePort', name=port.name,
              dimension=port.dimension.name, operator=port.reduce_op)
示例#20
0
 def visit_trigger(self, trigger):
     return E('Trigger', E("MathInline", trigger.rhs))
示例#21
0
 def to_xml(self):
     return E(self.element_name, str(self.value))
示例#22
0
 def to_xml(self):
     return E(self.element_name, self.value, index=self.index)
示例#23
0
 def item_to_xml(item):
     if isinstance(item, Reference):
         return item.to_xml()
     else:
         return E.Reference(item.name)
示例#24
0
 def visit_eventsendport(self, port):
     return E('EventSendPort', name=port.name)
示例#25
0
 def visit_analogsendport(self, port):
     return E('AnalogSendPort', name=port.name,
              dimension=port.dimension.name)
示例#26
0
 def to_xml(self):
     return E(self.element_name, self.operation.to_xml(), name=self.name)
示例#27
0
 def visit_assignment(self, assignment):
     return E('StateAssignment',
              E("MathInline", assignment.rhs),
              variable=assignment.lhs)
示例#28
0
 def to_xml(self):
     return E(self.element_name,
              url=self.url,
              mimetype=self.mimetype,
              columnName=self.columnName)
示例#29
0
 def visit_timederivative(self, time_derivative):
     return E('TimeDerivative',
              E("MathInline", time_derivative.rhs),
              variable=time_derivative.dependent_variable)
示例#30
0
 def to_xml(self):
     return E(self.element_name, *[r.to_xml() for r in self.rows])
示例#31
0
 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)