From 74e2953624138090d2b18f69b4929d675817e4bc Mon Sep 17 00:00:00 2001 From: Jarrod Pas <j.pas@usask.ca> Date: Tue, 25 Jul 2017 22:46:31 -0600 Subject: [PATCH] Fix Parameters differ from overridden 'process' method --- pydtn/communities/kclique.py | 3 ++- pydtn/communities/louvain.py | 3 ++- pydtn/core.py | 4 ++-- pydtn/network.py | 5 +++-- pydtn/traces/csvtrace.py | 3 ++- pydtn/traces/randomtrace.py | 4 ++-- 6 files changed, 13 insertions(+), 9 deletions(-) diff --git a/pydtn/communities/kclique.py b/pydtn/communities/kclique.py index 52d5dbd..cf731fe 100644 --- a/pydtn/communities/kclique.py +++ b/pydtn/communities/kclique.py @@ -10,7 +10,8 @@ class KCliqueCommunity(EpochCommunity): self.k = k self.threshold = threshold - def process(self, network): + def process(self, **kwargs): + network = kwargs['network'] while True: yield self.tick() g = self.next_epoch(self.env.now) diff --git a/pydtn/communities/louvain.py b/pydtn/communities/louvain.py index c94f478..7399943 100644 --- a/pydtn/communities/louvain.py +++ b/pydtn/communities/louvain.py @@ -10,7 +10,8 @@ class LouvainCommunity(EpochCommunity): def __init__(self, epoch=604800, **kwargs): super().__init__(epoch, **kwargs) - def process(self, network): + def process(self, **kwargs): + network = kwargs['network'] while True: yield self.tick() g = self.next_epoch(self.env.now) diff --git a/pydtn/core.py b/pydtn/core.py index 035179b..2410ff1 100644 --- a/pydtn/core.py +++ b/pydtn/core.py @@ -7,9 +7,9 @@ class Process: self.env = env self.__process = env.process(self.process(*args)) - def process(self, *args): + def process(self, **kwargs): + yield self.env.timeout(0) raise NotImplementedError - yield None class TickProcess(Process): diff --git a/pydtn/network.py b/pydtn/network.py index 7841e7a..a5c6580 100644 --- a/pydtn/network.py +++ b/pydtn/network.py @@ -135,7 +135,7 @@ class Node(TickProcess): for packet in packets_to_delete: self.buffer.remove(packet) - def process(self): + def process(self, **kwargs): '''''' while True: self.buffer.clean() @@ -232,7 +232,8 @@ class PacketGenerator(TickProcess): self.time_to_live = time_to_live self.packets = [] - def process(self, network): + def process(self, **kwargs): + network = kwargs['network'] packet_id = 0 def create(packet_id): source, dest = random.choice(network.links) diff --git a/pydtn/traces/csvtrace.py b/pydtn/traces/csvtrace.py index d5da192..373b7dd 100644 --- a/pydtn/traces/csvtrace.py +++ b/pydtn/traces/csvtrace.py @@ -15,9 +15,10 @@ class CSVTrace(Trace): duration, _, _, nodes = map(int, next(self.reader)) super().__init__(duration, nodes) - def process(self, network): + def process(self, **kwargs): '''''' env = self.env + network = kwargs['network'] for row in self.reader: time, a, b, state = map(int, row) diff --git a/pydtn/traces/randomtrace.py b/pydtn/traces/randomtrace.py index 942e5f9..536f645 100644 --- a/pydtn/traces/randomtrace.py +++ b/pydtn/traces/randomtrace.py @@ -20,10 +20,10 @@ class RandomTrace(TickTrace): self.min_toggles = min_toggles self.max_toggles = max_toggles - def process(self, network): + def process(self, **kwargs): '''''' env = self.env - links = network.links + links = kwargs['network'].links while env.now < self.duration: to_toggle = randint(self.min_toggles, self.max_toggles) -- GitLab