def test_event_copy(self): """ Test to make sure that EPConnectionEvent copies the underlying data on construction. """ s = Simulation() data = array([4,3]) epc = EPConnection() se = EPConnectionEvent(1,epc,data) se.data[0] = 5 assert data[0] != se.data[0], 'Matrices should be different' se2 = copy.copy(se) assert se is not se2, 'Objects are the same'
def test_event_copy(self): """ Test to make sure that EPConnectionEvent copies the underlying data on construction. """ s = Simulation() data = array([4, 3]) epc = EPConnection() se = EPConnectionEvent(1, epc, data) se.data[0] = 5 assert data[0] != se.data[0], 'Matrices should be different' se2 = copy.copy(se) assert se is not se2, 'Objects are the same'
def start(self): conn = self.simulation.connect(self.name, self.name, delay=self.period) e = EPConnectionEvent( self.simulation.time() + self.simulation.convert_to_time_type(self.phase), conn) self.simulation.enqueue_event(e) EventProcessor.start(self)
def send_output(self,src_port=None,data=None): """Send some data out to all connections on the given src_port.""" out_conns_on_src_port = [conn for conn in self.out_connections if self._port_match(conn.src_port,[src_port])] for conn in out_conns_on_src_port: if self.strict_tsettle != None: if self.activation_count < self.strict_tsettle: if len(conn.dest_port)>2 and conn.dest_port[2] == 'Afferent': continue self.verbose("Sending output on src_port %s via connection %s to %s" % (str(src_port), conn.name, conn.dest.name)) e=EPConnectionEvent(self.simulation.convert_to_time_type(conn.delay)+self.simulation.time(),conn,data) self.simulation.enqueue_event(e)