예제 #1
0
class Connection (Element) :
    def __init__ (self, structure) :
        super().__init__(structure)
        self.structure.connections.append(self)

        self._weights = Matrix()

    def __iter__ (self) :
        return iter(self._weights)

    def __repr__ (self, *args, **kw) :
        width  = self._weights.width()
        height = self._weights.height()

        # A mock "dimensions" object for the textual representation.
        dimensions = type('Dimensions', (), {'__repr__' : lambda self : '{}x{}'.format(width, height)})()

        return super().__repr__(dimensions, *args, **kw)

    @property
    def weights (self) :
        return self._weights
예제 #2
0
    def __init__ (self, structure) :
        super().__init__(structure)
        self.structure.connections.append(self)

        self._weights = Matrix()