Skip to content

Commit 55daffc

Browse files
committed
Merge pull request #24 from fenelon/master
Fix #23 fixes ValueError for hashes being deleted while running
2 parents 0cd6482 + 54f820a commit 55daffc

File tree

4 files changed

+13
-3
lines changed

4 files changed

+13
-3
lines changed

CHANGES

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
ChangeLog for RMA
22
--------------------
3+
- 0.1.14
4+
5+
* Fix fails with ValueError if a key containing Hash was removed.
6+
Closes issue #23.
7+
38
- 0.1.13
49

510
* Fix fails with TypeError if a key containing integer was removed.

rma/__pkginfo__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
num_version = (0, 1, 13)
1+
num_version = (0, 1, 14)
22
version = '.'.join([str(num) for num in num_version])
33

44
classifiers = [

rma/rule/Hash.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,9 @@ def __init__(self, all_obj, total):
5757
self.fieldUsedBytes = sum(obj.fieldUsedBytes for obj in g1)
5858
self.fieldAlignedBytes = sum(obj.fieldAlignedBytes for obj in g2)
5959

60-
if total > 1:
60+
if total == 0:
61+
self.fieldAvgCount = 0
62+
elif total > 1:
6163
self.fieldAvgCount = statistics.mean(obj.count for obj in g3)
6264
else:
6365
self.fieldAvgCount = min((obj.count for obj in g3))
@@ -101,7 +103,7 @@ def analyze(self, keys, total=0):
101103
agg.fieldAvgCount,
102104
agg.fieldUsedBytes,
103105
agg.fieldAlignedBytes,
104-
agg.fieldAlignedBytes / agg.fieldUsedBytes,
106+
agg.fieldAlignedBytes / (agg.fieldUsedBytes if agg.fieldUsedBytes > 0 else 1),
105107
agg.valueUsedBytes,
106108
agg.valueAlignedBytes,
107109
agg.valueAlignedBytes / (agg.valueUsedBytes if agg.valueUsedBytes > 0 else 1),

rma/rule/KeyString.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@ def analyze(self, keys, total=0):
4949
progress_iterator((StringEntry(value=x["name"]) for x in data), progress), 3)
5050

5151
total_elements = len(data)
52+
if total_elements == 0:
53+
continue
54+
5255
aligned = sum(obj.aligned for obj in aligned_iter)
5356
used_bytes_generator = (obj.useful_bytes for obj in used_bytes_iter)
5457
useful_iter, min_iter, max_iter, mean_iter = tee(used_bytes_generator, 4)

0 commit comments

Comments
 (0)