Skip to content

Commit 96fdd4e

Browse files
committed
Group data collection by common group object
1 parent b9d817a commit 96fdd4e

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

mesa/experimental/measure.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,13 @@ def run():
7272
def __init__(self, model, attributes):
7373
self.model = model
7474
self.attributes = attributes
75-
self.data_collection = defaultdict(list)
75+
self.data_collection = defaultdict(lambda: defaultdict(list))
7676

7777
def collect(self):
7878
for name in self.attributes:
7979
attribute = getattr(self.model, name)
80+
group = "model"
8081
if isinstance(attribute, Measure):
82+
group = attribute.group
8183
attribute = attribute.value
82-
self.data_collection[name] = attribute
84+
self.data_collection[group][name].append(attribute)

0 commit comments

Comments
 (0)