Beispiel #1
0
    def __init__(self, component):
        ComponentValidatorPerNamespace.__init__(self,
                                     explicitly_require_action_overrides=False)

        self.connected_regimes_from_regime = defaultdict(set)
        self.regimes_in_namespace = defaultdict(set)

        self.visit(component)

        def add_connected_regimes_recursive(regime, connected):
            connected.add(regime)
            for r in self.connected_regimes_from_regime[regime]:
                if not r in connected:
                    add_connected_regimes_recursive(r, connected)

        for namespace, regimes in self.regimes_in_namespace.iteritems():

            # Perhaps we have no transition graph; this is OK:
            if len(regimes) == 0:
                continue

            connected = set()
            add_connected_regimes_recursive(regimes[0], connected)
            if len(connected) != len(self.regimes_in_namespace[namespace]):
                raise NineMLRuntimeError('Transition graph is contains '
                                         'islands')
Beispiel #2
0
    def __init__(self, component):
        ComponentValidatorPerNamespace.__init__(self, explicitly_require_action_overrides=True)

        self.all_objects = list()

        self.visit(component)

        nineml.utility.assert_no_duplicates(self.all_objects)
Beispiel #3
0
    def __init__(self, component):
        ComponentValidatorPerNamespace.__init__(self, explicitly_require_action_overrides=False)
        self.sv_declared = defaultdict(list)
        self.state_assignments_lhses = defaultdict(list)

        self.visit(component)

        for namespace, state_assignments_lhs in self.state_assignments_lhses.iteritems():
            for td in state_assignments_lhs:
                if not td in self.sv_declared[namespace]:
                    err = 'Not Assigning to state-variable: %s' % state_assignment
                    raise nineml.exceptions.NineMLRuntimeError(err)
Beispiel #4
0
    def __init__(self, component):
        ComponentValidatorPerNamespace.__init__(self, explicitly_require_action_overrides=False)
        self.sv_declared = defaultdict(list)
        self.time_derivatives_used = defaultdict(list)

        self.visit(component)

        for namespace, time_derivatives in self.time_derivatives_used.iteritems():
            for td in time_derivatives:
                if not td in self.sv_declared[namespace]:
                    err = 'StateVariable not declared: %s' % td
                    raise nineml.exceptions.NineMLRuntimeError(err)
Beispiel #5
0
    def __init__(self, component):
        ComponentValidatorPerNamespace.__init__(self,
                                     explicitly_require_action_overrides=False)

        self.ports = defaultdict(list)
        self.portconnections = list()

        self.visit(component)

        connected_recv_ports = set()

        # Check for duplicate connections in the
        # portconnections. This can only really happen in the
        # case of connecting 'send to reduce ports' more than once.
        seen_port_connections = set()
        for pc in self.portconnections:
            if pc in seen_port_connections:
                err = 'Duplicate Port Connection: %s -> %s' % (pc[0], pc[1])
                raise NineMLRuntimeError(err)
            seen_port_connections.add(pc)

        # Check each source and sink exist,
        # and that each recv port is connected at max once.
        for src, sink in self.portconnections:
            if not src in self.ports:
                raise NineMLRuntimeError(
                    'Unable to find port specified in connection: %s' %
                    (src))
            if self.ports[src].is_incoming():
                raise NineMLRuntimeError(
                    'Port was specified as a source, but is incoming: %s' %
                    (src))

            if not sink in self.ports:
                raise NineMLRuntimeError(
                    'Unable to find port specified in connection: %s' %
                    (sink))

            if not self.ports[sink].is_incoming():
                raise NineMLRuntimeError(
                    'Port was specified as a sink, but is not incoming: %s' %
                    (sink))

            if self.ports[sink].mode == 'recv':
                if self.ports[sink] in connected_recv_ports:
                    raise NineMLRuntimeError(
                        "Port was 'recv' and specified twice: %s" % (sink))
                connected_recv_ports.add(self.ports[sink])
Beispiel #6
0
    def __init__(self, component):
        ComponentValidatorPerNamespace.__init__(self,
                                     explicitly_require_action_overrides=False)

        self.available_symbols = defaultdict(list)
        self.aliases = defaultdict(list)
        self.time_derivatives = defaultdict(list)
        self.state_assignments = defaultdict(list)

        self.visit(component)

        excludes = get_reserved_and_builtin_symbols()

        # Check Aliases:
        for ns, aliases in self.aliases.iteritems():
            for alias in aliases:
                for rhs_atom in alias.rhs_atoms:
                    if rhs_atom in excludes:
                        continue
                    if not rhs_atom in self.available_symbols[ns]:
                        err = ('Unresolved Symbol in Alias: %s [%s]' %
                               (rhs_atom, alias))
                        raise NineMLRuntimeError(err)

        # Check TimeDerivatives:
        for ns, timederivatives in self.time_derivatives.iteritems():
            for timederivative in timederivatives:
                for rhs_atom in timederivative.rhs_atoms:
                    if (not rhs_atom in self.available_symbols[ns] and
                        not rhs_atom in excludes):
                        err = ('Unresolved Symbol in Time Derivative: %s [%s]'
                               % (rhs_atom, timederivative))
                        raise NineMLRuntimeError(err)

        # Check StateAssignments
        for ns, state_assignments in self.state_assignments.iteritems():
            for state_assignment in state_assignments:
                for rhs_atom in state_assignment.rhs_atoms:
                    if (not rhs_atom in self.available_symbols[ns] and
                        not rhs_atom in excludes):
                        err = ('Unresolved Symbol in Assignment: %s [%s]' %
                               (rhs_atom, state_assignment))
                        raise NineMLRuntimeError(err)
Beispiel #7
0
 def __init__(self, component):
     ComponentValidatorPerNamespace.__init__(self,
                                  explicitly_require_action_overrides=False)
     self.visit(component)