scripts: maps: Fixed divide-by-zero when packing blocks into small maps
This can be hit when dealing with very small maps, which is common since we're rendering to the terminal. Not crashing here at least allows the header/usage string to be shown.
This commit is contained in:
+2
-2
@@ -4599,10 +4599,10 @@ def main_(ring, disk, mroots=None, *,
|
||||
block_cols_ = 1
|
||||
block_rows_ = len(bmap)
|
||||
while (abs(((canvas.width/(block_cols_*2))
|
||||
/ (canvas.height/mt.ceil(block_rows_ / 2)))
|
||||
/ max(canvas.height/mt.ceil(block_rows_/2), 1))
|
||||
- block_ratio)
|
||||
< abs(((canvas.width/block_cols_)
|
||||
/ (canvas.height/block_rows_)))
|
||||
/ max(canvas.height/block_rows_, 1)))
|
||||
- block_ratio):
|
||||
block_cols_ *= 2
|
||||
block_rows_ = mt.ceil(block_rows_ / 2)
|
||||
|
||||
@@ -4919,10 +4919,10 @@ def main(disk, output, mroots=None, *,
|
||||
block_cols_ = 1
|
||||
block_rows_ = len(bmap)
|
||||
while (abs(((width__/(block_cols_*2))
|
||||
/ (height__/mt.ceil(block_rows_ / 2)))
|
||||
/ max(height__/mt.ceil(block_rows_/2), 1))
|
||||
- block_ratio)
|
||||
< abs(((width__/block_cols_)
|
||||
/ (height__/block_rows_)))
|
||||
/ max(height__/block_rows_, 1)))
|
||||
- block_ratio):
|
||||
block_cols_ *= 2
|
||||
block_rows_ = mt.ceil(block_rows_ / 2)
|
||||
|
||||
+2
-2
@@ -1795,10 +1795,10 @@ def main(path='-', *,
|
||||
block_cols_ = 1
|
||||
block_rows_ = len(bmap)
|
||||
while (abs(((canvas.width/(block_cols_*2))
|
||||
/ (canvas.height/mt.ceil(block_rows_ / 2)))
|
||||
/ max(canvas.height/mt.ceil(block_rows_/2), 1))
|
||||
- block_ratio)
|
||||
< abs(((canvas.width/block_cols_)
|
||||
/ (canvas.height/block_rows_)))
|
||||
/ max(canvas.height/block_rows_, 1)))
|
||||
- block_ratio):
|
||||
block_cols_ *= 2
|
||||
block_rows_ = mt.ceil(block_rows_ / 2)
|
||||
|
||||
Reference in New Issue
Block a user