From 057859141dc10ec10bc45d1b6a5d4174659170c2 Mon Sep 17 00:00:00 2001 From: Galen Seilis Date: Wed, 1 Nov 2023 18:08:00 -0700 Subject: [PATCH] Update tracker parameter in simulation.py Default argument was a mutable type. Generally the advice I've read is to only use immutable types as defaults. Although I was not running into this issue, it can in principle lead to unusual behavior when a default argument is mutable. In this case I have changed the default argument of `tracker` to `None`, but when this happens the same tracker will be assigned as before. --- ciw/simulation.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/ciw/simulation.py b/ciw/simulation.py index d2adbe3..5279550 100644 --- a/ciw/simulation.py +++ b/ciw/simulation.py @@ -22,7 +22,7 @@ def __init__( network, exact=False, name="Simulation", - tracker=trackers.StateTracker(), + tracker=None, deadlock_detector=deadlock.NoDetection(), node_class=None, arrival_node_class=None, @@ -51,7 +51,10 @@ def __init__( self.nodes = [self.ArrivalNodeType(self)] + self.transitive_nodes + [ExitNode()] self.active_nodes = self.nodes[:-1] self.nodes[0].initialise() - self.statetracker = tracker + if tracker is None: + self.statetracker = trackers.StateTracker() + else: + self.statetracker = tracker self.statetracker.initialise(self) self.times_dictionary = {self.statetracker.hash_state(): 0.0} self.times_to_deadlock = {}