From 4e8f064bccf228009bddbe9adff4e20bcf7d9533 Mon Sep 17 00:00:00 2001 From: Tamerlan Tabolov Date: Sat, 6 Jul 2024 01:40:09 +0200 Subject: [PATCH] Fix writing constants in lib.py I believe this change fixes the problem, when visualizer crashes with "'int' object has no attribute 'inputs'" when user assigns a constant to a variable --- lib.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/lib.py b/lib.py index 0f0f7f4..7ea6fba 100644 --- a/lib.py +++ b/lib.py @@ -220,6 +220,7 @@ def draw_connect(tab, dia, loc2, color, con): [ myconnect(dia, loc2, color, con, (tab.name,) + loc, inp.location) for (loc, val) in tab.incoming + if isintacnce(val, ScalarHistory) for inp in val.inputs ] ) @@ -371,11 +372,12 @@ def score(self, results): count["out_writes"] += 1 else: count["shared_writes"] += 1 - for ins in inc[1].inputs: - if ins.location[0].startswith("S"): - count["shared_reads"] += 1 - else: - count["in_reads"] += 1 + if isintance(inc[1], ScalarHistory): + for ins in inc[1].inputs: + if ins.location[0].startswith("S"): + count["shared_reads"] += 1 + else: + count["in_reads"] += 1 for k in count: if count[k] > full[k]: full[k] = count[k]