예제 #1
0
    def _grouped_in_projections(self, ptype):
        """
        Return a dictionary of lists of incoming Projections, grouped by type.

        Each projection of type <ptype> is grouped according to the
        name of the port, into a single list within the dictionary.

        The entry None will contain those that are not of type
        <ptype>, while the other entries will contain a list of
        Projections, each of which has type ptype.

        Example: to obtain the lists of projections that should be
        jointly normalised together, call
        __grouped_in_projection('JointNormalize').
        """
        in_proj = KeyedList()
        in_proj[None] = []  # Independent (ungrouped) connections

        for c in self.in_connections:
            d = c.dest_port
            if not isinstance(c, Projection):
                self.debug("Skipping non-Projection " + c.name)
            elif isinstance(d, tuple) and len(d) > 2 and d[1] == ptype:
                if in_proj.get(d[2]):
                    in_proj[d[2]].append(c)
                else:
                    in_proj[d[2]] = [c]
            # elif isinstance(d,tuple):
            #    raise ValueError("Unable to determine appropriate action for dest_port: %s (connection %s)." % (d,c.name))
            else:
                in_proj[None].append(c)

        return in_proj
예제 #2
0
    def _grouped_in_projections(self,ptype):
        """
        Return a dictionary of lists of incoming Projections, grouped by type.

        Each projection of type <ptype> is grouped according to the
        name of the port, into a single list within the dictionary.

        The entry None will contain those that are not of type
        <ptype>, while the other entries will contain a list of
        Projections, each of which has type ptype.

        Example: to obtain the lists of projections that should be
        jointly normalised together, call
        __grouped_in_projection('JointNormalize').
        """
        in_proj = KeyedList()
        in_proj[None]=[] # Independent (ungrouped) connections

        for c in self.in_connections:
            d = c.dest_port
            if not isinstance(c,Projection):
                self.debug("Skipping non-Projection "+c.name)
            elif isinstance(d,tuple) and len(d)>2 and d[1]==ptype:
                if in_proj.get(d[2]):
                    in_proj[d[2]].append(c)
                else:
                    in_proj[d[2]]=[c]
            #elif isinstance(d,tuple):
            #    raise ValueError("Unable to determine appropriate action for dest_port: %s (connection %s)." % (d,c.name))
            else:
                in_proj[None].append(c)

        return in_proj