Skip to content

Commit 3e5f447

Browse files
committed
Fix #23 fails with ValueError if a key containing List/Set was removed.
1 parent 55daffc commit 3e5f447

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

rma/rule/List.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,13 @@ def __init__(self, all_obj, total):
5050

5151
self.encoding = pref_encoding([obj.encoding for obj in encode_iter], redis_encoding_id_to_str)
5252
self.system = sum(obj.system for obj in sys_iter)
53-
if total > 1:
53+
54+
if total == 0:
55+
self.fieldAvgCount = 0
56+
self.fieldStdev = 0
57+
self.fieldMinCount = 0
58+
self.fieldMaxCount = 0
59+
elif total > 1:
5460
self.fieldAvgCount = statistics.mean(obj.count for obj in avg_iter)
5561
self.fieldStdev = statistics.stdev(obj.count for obj in stdev_iter)
5662
self.fieldMinCount = min((obj.count for obj in min_iter))

rma/rule/Set.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,10 @@ def __init__(self, all_obj, total):
4242

4343
self.encoding = pref_encoding([obj.encoding for obj in g00], redis_encoding_id_to_str)
4444
self.system = sum(obj.system for obj in g0)
45-
if total > 1:
45+
46+
if total == 0:
47+
self.fieldAvgCount = 0
48+
elif total > 1:
4649
self.fieldAvgCount = statistics.mean(obj.count for obj in g3)
4750
else:
4851
self.fieldAvgCount = min((obj.count for obj in g3))

0 commit comments

Comments
 (0)