From 91236094c321b06c82ac31013b0775e4cb0c1ae7 Mon Sep 17 00:00:00 2001 From: Luke Kenneth Casson Leighton Date: Wed, 29 Sep 2021 17:12:51 +0100 Subject: [PATCH] add assert to check partition jump point size --- src/ieee754/part_mul_add/partpoints.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/ieee754/part_mul_add/partpoints.py b/src/ieee754/part_mul_add/partpoints.py index 8ae23810..88da9ae9 100644 --- a/src/ieee754/part_mul_add/partpoints.py +++ b/src/ieee754/part_mul_add/partpoints.py @@ -37,14 +37,15 @@ def make_partition2(mask, width): mask len = 7, width == 64 will return: {8: mask[0], 16: mask[1], 24: mask[2], .... 56: mask[6]} """ + if isinstance(mask, dict): # convert dict/partpoints to sequential list + mask = list(mask.values()) mlen = len(mask) + 1 # ONE MORE partitions than break-points jumpsize = width // mlen # amount to jump by (size of each partition) ppoints = {} ppos = jumpsize + print ("make_partition2", width, mask, len(mask), mlen, jumpsize) + assert jumpsize > 0, "incorrect width // mlen (%d // %d)" % (width, mlen) midx = 0 - if isinstance(mask, dict): # convert dict/partpoints to sequential list - mask = list(mask.values()) - print ("make_partition2", width, mask, mlen, jumpsize) while ppos < width and midx < mlen: # -1, ignore last bit print (" make_partition2", ppos, width, midx, mlen) ppoints[ppos] = mask[midx] -- 2.30.2