diff --git a/scripts/amor.py b/scripts/amor.py index 9dd83093..083e339e 100755 --- a/scripts/amor.py +++ b/scripts/amor.py @@ -6,7 +6,7 @@ import collections as co import csv import itertools as it -import math as m +import math as mt import os @@ -36,7 +36,7 @@ def dat(x): try: return float(x) # just don't allow infinity or nan - if m.isinf(x) or m.isnan(x): + if mt.isinf(x) or mt.isnan(x): raise ValueError("invalid dat %r" % x) except ValueError: pass diff --git a/scripts/avg.py b/scripts/avg.py index b917bb35..92cbe0d9 100755 --- a/scripts/avg.py +++ b/scripts/avg.py @@ -6,7 +6,7 @@ import collections as co import csv import itertools as it -import math as m +import math as mt import os @@ -36,7 +36,7 @@ def dat(x): try: return float(x) # just don't allow infinity or nan - if m.isinf(x) or m.isnan(x): + if mt.isinf(x) or mt.isnan(x): raise ValueError("invalid dat %r" % x) except ValueError: pass @@ -182,23 +182,23 @@ def main(csv_paths, output, *, else {meas: meas__+'+'+meas_})) if sum_: append('sum', lambda vs: sum(vs)) - if prod: append('prod', lambda vs: m.prod(vs)) + if prod: append('prod', lambda vs: mt.prod(vs)) if min_: append('min', lambda vs: min(vs, default=0)) if max_: append('max', lambda vs: max(vs, default=0)) if bnd: append('bnd', lambda vs: min(vs, default=0)) if bnd: append('bnd', lambda vs: max(vs, default=0)) if avg: append('avg', lambda vs: sum(vs) / max(len(vs), 1)) if stddev: append('stddev', lambda vs: ( - lambda avg: m.sqrt( + lambda avg: mt.sqrt( sum((v - avg)**2 for v in vs) / max(len(vs), 1)) )(sum(vs) / max(len(vs), 1))) if gmean: append('gmean', lambda vs: - m.prod(float(v) for v in vs)**(1 / max(len(vs), 1))) + mt.prod(float(v) for v in vs)**(1 / max(len(vs), 1))) if gstddev: append('gstddev', lambda vs: ( - lambda gmean: m.exp(m.sqrt( - sum(m.log(v/gmean)**2 for v in vs) / max(len(vs), 1))) - if gmean else m.inf - )(m.prod(float(v) for v in vs)**(1 / max(len(vs), 1)))) + lambda gmean: mt.exp(mt.sqrt( + sum(mt.log(v/gmean)**2 for v in vs) / max(len(vs), 1))) + if gmean else mt.inf + )(mt.prod(float(v) for v in vs)**(1 / max(len(vs), 1)))) # write results to CSVS with openio(output, 'w') as f: diff --git a/scripts/bench.py b/scripts/bench.py index 0d379633..a19adf5a 100755 --- a/scripts/bench.py +++ b/scripts/bench.py @@ -14,7 +14,6 @@ import csv import errno import fnmatch import itertools as it -import math as m import os import pty import re diff --git a/scripts/code.py b/scripts/code.py index b920137f..1660bc6d 100755 --- a/scripts/code.py +++ b/scripts/code.py @@ -16,7 +16,7 @@ import collections as co import csv import difflib import itertools as it -import math as m +import math as mt import os import re import shlex @@ -40,24 +40,24 @@ class RInt(co.namedtuple('RInt', 'x')): except ValueError: # also accept +-∞ and +-inf if re.match('^\s*\+?\s*(?:∞|inf)\s*$', x): - x = m.inf + x = mt.inf elif re.match('^\s*-\s*(?:∞|inf)\s*$', x): - x = -m.inf + x = -mt.inf else: raise - assert isinstance(x, int) or m.isinf(x), x + assert isinstance(x, int) or mt.isinf(x), x return super().__new__(cls, x) def __str__(self): - if self.x == m.inf: + if self.x == mt.inf: return '∞' - elif self.x == -m.inf: + elif self.x == -mt.inf: return '-∞' else: return str(self.x) def __int__(self): - assert not m.isinf(self.x) + assert not mt.isinf(self.x) return self.x def __float__(self): @@ -71,9 +71,9 @@ class RInt(co.namedtuple('RInt', 'x')): new = self.x if self else 0 old = other.x if other else 0 diff = new - old - if diff == +m.inf: + if diff == +mt.inf: return '%7s' % '+∞' - elif diff == -m.inf: + elif diff == -mt.inf: return '%7s' % '-∞' else: return '%+7d' % diff @@ -81,16 +81,16 @@ class RInt(co.namedtuple('RInt', 'x')): def ratio(self, other): new = self.x if self else 0 old = other.x if other else 0 - if m.isinf(new) and m.isinf(old): + if mt.isinf(new) and mt.isinf(old): return 0.0 - elif m.isinf(new): - return +m.inf - elif m.isinf(old): - return -m.inf + elif mt.isinf(new): + return +mt.inf + elif mt.isinf(old): + return -mt.inf elif not old and not new: return 0.0 elif not old: - return +m.inf + return +mt.inf else: return (new-old) / old @@ -446,8 +446,8 @@ def table(Result, results, diff_results=None, *, (getattr(r, k).table() if getattr(r, k, None) is not None else types[k].none, - (lambda t: ['+∞%'] if t == +m.inf - else ['-∞%'] if t == -m.inf + (lambda t: ['+∞%'] if t == +mt.inf + else ['-∞%'] if t == -mt.inf else ['%+.1f%%' % (100*t)])( types[k].ratio( getattr(r, k, None), @@ -466,8 +466,8 @@ def table(Result, results, diff_results=None, *, (types[k].diff( getattr(r, k, None), getattr(diff_r, k, None)), - (lambda t: ['+∞%'] if t == +m.inf - else ['-∞%'] if t == -m.inf + (lambda t: ['+∞%'] if t == +mt.inf + else ['-∞%'] if t == -mt.inf else ['%+.1f%%' % (100*t)] if t else [])( types[k].ratio( diff --git a/scripts/cov.py b/scripts/cov.py index a8091fb9..7c0f4cd5 100755 --- a/scripts/cov.py +++ b/scripts/cov.py @@ -16,7 +16,7 @@ import collections as co import csv import itertools as it import json -import math as m +import math as mt import os import re import shlex @@ -40,24 +40,24 @@ class RInt(co.namedtuple('RInt', 'x')): except ValueError: # also accept +-∞ and +-inf if re.match('^\s*\+?\s*(?:∞|inf)\s*$', x): - x = m.inf + x = mt.inf elif re.match('^\s*-\s*(?:∞|inf)\s*$', x): - x = -m.inf + x = -mt.inf else: raise - assert isinstance(x, int) or m.isinf(x), x + assert isinstance(x, int) or mt.isinf(x), x return super().__new__(cls, x) def __str__(self): - if self.x == m.inf: + if self.x == mt.inf: return '∞' - elif self.x == -m.inf: + elif self.x == -mt.inf: return '-∞' else: return str(self.x) def __int__(self): - assert not m.isinf(self.x) + assert not mt.isinf(self.x) return self.x def __float__(self): @@ -71,9 +71,9 @@ class RInt(co.namedtuple('RInt', 'x')): new = self.x if self else 0 old = other.x if other else 0 diff = new - old - if diff == +m.inf: + if diff == +mt.inf: return '%7s' % '+∞' - elif diff == -m.inf: + elif diff == -mt.inf: return '%7s' % '-∞' else: return '%+7d' % diff @@ -81,16 +81,16 @@ class RInt(co.namedtuple('RInt', 'x')): def ratio(self, other): new = self.x if self else 0 old = other.x if other else 0 - if m.isinf(new) and m.isinf(old): + if mt.isinf(new) and mt.isinf(old): return 0.0 - elif m.isinf(new): - return +m.inf - elif m.isinf(old): - return -m.inf + elif mt.isinf(new): + return +mt.inf + elif mt.isinf(old): + return -mt.inf elif not old and not new: return 0.0 elif not old: - return +m.inf + return +mt.inf else: return (new-old) / old @@ -127,8 +127,8 @@ class RFrac(co.namedtuple('RFrac', 'a,b')): def notes(self): t = self.a.x/self.b.x if self.b.x else 1.0 - return ['∞%' if t == +m.inf - else '-∞%' if t == -m.inf + return ['∞%' if t == +mt.inf + else '-∞%' if t == -mt.inf else '%.1f%%' % (100*t)] def diff(self, other): @@ -434,8 +434,8 @@ def table(Result, results, diff_results=None, *, (getattr(r, k).table() if getattr(r, k, None) is not None else types[k].none, - (lambda t: ['+∞%'] if t == +m.inf - else ['-∞%'] if t == -m.inf + (lambda t: ['+∞%'] if t == +mt.inf + else ['-∞%'] if t == -mt.inf else ['%+.1f%%' % (100*t)])( types[k].ratio( getattr(r, k, None), @@ -454,8 +454,8 @@ def table(Result, results, diff_results=None, *, (types[k].diff( getattr(r, k, None), getattr(diff_r, k, None)), - (lambda t: ['+∞%'] if t == +m.inf - else ['-∞%'] if t == -m.inf + (lambda t: ['+∞%'] if t == +mt.inf + else ['-∞%'] if t == -mt.inf else ['%+.1f%%' % (100*t)] if t else [])( types[k].ratio( diff --git a/scripts/data.py b/scripts/data.py index 7f00ad9a..26848851 100755 --- a/scripts/data.py +++ b/scripts/data.py @@ -16,7 +16,7 @@ import collections as co import csv import difflib import itertools as it -import math as m +import math as mt import os import re import shlex @@ -40,24 +40,24 @@ class RInt(co.namedtuple('RInt', 'x')): except ValueError: # also accept +-∞ and +-inf if re.match('^\s*\+?\s*(?:∞|inf)\s*$', x): - x = m.inf + x = mt.inf elif re.match('^\s*-\s*(?:∞|inf)\s*$', x): - x = -m.inf + x = -mt.inf else: raise - assert isinstance(x, int) or m.isinf(x), x + assert isinstance(x, int) or mt.isinf(x), x return super().__new__(cls, x) def __str__(self): - if self.x == m.inf: + if self.x == mt.inf: return '∞' - elif self.x == -m.inf: + elif self.x == -mt.inf: return '-∞' else: return str(self.x) def __int__(self): - assert not m.isinf(self.x) + assert not mt.isinf(self.x) return self.x def __float__(self): @@ -71,9 +71,9 @@ class RInt(co.namedtuple('RInt', 'x')): new = self.x if self else 0 old = other.x if other else 0 diff = new - old - if diff == +m.inf: + if diff == +mt.inf: return '%7s' % '+∞' - elif diff == -m.inf: + elif diff == -mt.inf: return '%7s' % '-∞' else: return '%+7d' % diff @@ -81,16 +81,16 @@ class RInt(co.namedtuple('RInt', 'x')): def ratio(self, other): new = self.x if self else 0 old = other.x if other else 0 - if m.isinf(new) and m.isinf(old): + if mt.isinf(new) and mt.isinf(old): return 0.0 - elif m.isinf(new): - return +m.inf - elif m.isinf(old): - return -m.inf + elif mt.isinf(new): + return +mt.inf + elif mt.isinf(old): + return -mt.inf elif not old and not new: return 0.0 elif not old: - return +m.inf + return +mt.inf else: return (new-old) / old @@ -446,8 +446,8 @@ def table(Result, results, diff_results=None, *, (getattr(r, k).table() if getattr(r, k, None) is not None else types[k].none, - (lambda t: ['+∞%'] if t == +m.inf - else ['-∞%'] if t == -m.inf + (lambda t: ['+∞%'] if t == +mt.inf + else ['-∞%'] if t == -mt.inf else ['%+.1f%%' % (100*t)])( types[k].ratio( getattr(r, k, None), @@ -466,8 +466,8 @@ def table(Result, results, diff_results=None, *, (types[k].diff( getattr(r, k, None), getattr(diff_r, k, None)), - (lambda t: ['+∞%'] if t == +m.inf - else ['-∞%'] if t == -m.inf + (lambda t: ['+∞%'] if t == +mt.inf + else ['-∞%'] if t == -mt.inf else ['%+.1f%%' % (100*t)] if t else [])( types[k].ratio( diff --git a/scripts/dbgbmap.py b/scripts/dbgbmap.py index 2f85e8ab..79d10a84 100755 --- a/scripts/dbgbmap.py +++ b/scripts/dbgbmap.py @@ -4,7 +4,7 @@ import bisect import collections as co import functools as ft import itertools as it -import math as m +import math as mt import os import shutil import struct @@ -269,9 +269,9 @@ def lebesgue_curve(width, height): # we create a truncated Z-curve by simply filtering out the points # that are outside our region curve = [] - for i in range(2**(2*m.ceil(m.log2(max(width, height))))): + for i in range(2**(2*mt.ceil(mt.log2(max(width, height))))): # we just operate on binary strings here because it's easier - b = '{:0{}b}'.format(i, 2*m.ceil(m.log2(i+1)/2)) + b = '{:0{}b}'.format(i, 2*mt.ceil(mt.log2(i+1)/2)) x = int(b[1::2], 2) if b[1::2] else 0 y = int(b[0::2], 2) if b[0::2] else 0 if x < width and y < height: @@ -1330,8 +1330,8 @@ def main(disk, mroots=None, *, # and then print the bmap for row in range( - m.ceil(bmap.height/4) if braille - else m.ceil(bmap.height/2) if dots + mt.ceil(bmap.height/4) if braille + else mt.ceil(bmap.height/2) if dots else bmap.height): line = bmap.draw(row, mdirs=mdirs, diff --git a/scripts/dbgbtree.py b/scripts/dbgbtree.py index eb742560..117f8295 100755 --- a/scripts/dbgbtree.py +++ b/scripts/dbgbtree.py @@ -3,7 +3,7 @@ import bisect import collections as co import itertools as it -import math as m +import math as mt import os import struct @@ -920,7 +920,7 @@ def main(disk, roots=None, *, # dynamically size the id field - w_width = m.ceil(m.log10(max(1, btree.weight)+1)) + w_width = mt.ceil(mt.log10(max(1, btree.weight)+1)) # prbyd here means the last rendered rbyd, we update # in dbg_branch to always print interleaved addresses diff --git a/scripts/dbglfs.py b/scripts/dbglfs.py index 256202f4..6e90077a 100755 --- a/scripts/dbglfs.py +++ b/scripts/dbglfs.py @@ -4,7 +4,7 @@ import bisect import collections as co import functools as ft import itertools as it -import math as m +import math as mt import os import struct @@ -1461,7 +1461,7 @@ def dbg_fstruct(f, block_size, mdir, rid, tag, j, d, data, *, # dynamically size the id field - w_width = m.ceil(m.log10(max(1, btree.weight)+1)) + w_width = mt.ceil(mt.log10(max(1, btree.weight)+1)) # prbyd here means the last rendered rbyd, we update # in dbg_branch to always print interleaved addresses @@ -1719,7 +1719,7 @@ def main(disk, mroots=None, *, # determine the mleaf_weight from the block_size, this is just for # printing purposes - mleaf_weight = 1 << m.ceil(m.log2(block_size // 8)) + mleaf_weight = 1 << mt.ceil(mt.log2(block_size // 8)) # before we print, we need to do a pass for a few things: # - find the actual mroot @@ -1888,7 +1888,7 @@ def main(disk, mroots=None, *, width_ = max(width_, width__) return 1+depth_, width_ - depth, f_width = rec_f_width(0, args.get('depth') or m.inf) + depth, f_width = rec_f_width(0, args.get('depth') or mt.inf) # adjust to make space for max depth f_width += 4*(depth-1) @@ -1906,8 +1906,8 @@ def main(disk, mroots=None, *, # dynamically size the id field w_width = max( - m.ceil(m.log10(max(1, bweight//mleaf_weight)+1)), - m.ceil(m.log10(max(1, rweight)+1)), + mt.ceil(mt.log10(max(1, bweight//mleaf_weight)+1)), + mt.ceil(mt.log10(max(1, rweight)+1)), # in case of -1.-1 2) @@ -2162,7 +2162,7 @@ def main(disk, mroots=None, *, prefixes[2+(i==len(dir)-1)] + "| ", prefixes[2+(i==len(dir)-1)] + " ")) - rec_dir(0, args.get('depth') or m.inf) + rec_dir(0, args.get('depth') or mt.inf) if args.get('error_on_corrupt') and corrupted: sys.exit(2) diff --git a/scripts/dbgmtree.py b/scripts/dbgmtree.py index 2ae1e195..85182963 100755 --- a/scripts/dbgmtree.py +++ b/scripts/dbgmtree.py @@ -3,7 +3,7 @@ import bisect import collections as co import itertools as it -import math as m +import math as mt import os import struct @@ -879,7 +879,7 @@ def main(disk, mroots=None, *, # determine the mleaf_weight from the block_size, this is just for # printing purposes - mleaf_weight = 1 << m.ceil(m.log2(block_size // 8)) + mleaf_weight = 1 << mt.ceil(mt.log2(block_size // 8)) # before we print, we need to do a pass for a few things: # - find the actual mroot @@ -1510,8 +1510,8 @@ def main(disk, mroots=None, *, # dynamically size the id field w_width = max( - m.ceil(m.log10(max(1, bweight//mleaf_weight)+1)), - m.ceil(m.log10(max(1, rweight)+1)), + mt.ceil(mt.log10(max(1, bweight//mleaf_weight)+1)), + mt.ceil(mt.log10(max(1, rweight)+1)), # in case of -1.-1 2) diff --git a/scripts/dbgrbyd.py b/scripts/dbgrbyd.py index 9c240015..feca2ae0 100755 --- a/scripts/dbgrbyd.py +++ b/scripts/dbgrbyd.py @@ -3,7 +3,7 @@ import bisect import collections as co import itertools as it -import math as m +import math as mt import os import struct @@ -513,7 +513,7 @@ def dbg_log(data, block_size, rev, eoff, weight, *, weight_ = max(weight_, weight__) trunk_ = 0 - w_width = m.ceil(m.log10(max(1, weight_)+1)) + w_width = mt.ceil(mt.log10(max(1, weight_)+1)) # print revision count if args.get('raw'): @@ -839,7 +839,7 @@ def dbg_tree(data, block_size, rev, trunk, weight, *, # dynamically size the id field - w_width = m.ceil(m.log10(max(1, weight)+1)) + w_width = mt.ceil(mt.log10(max(1, weight)+1)) rid, tag = -1, 0 for i in it.count(): diff --git a/scripts/perf.py b/scripts/perf.py index d3bce0d0..b277918d 100755 --- a/scripts/perf.py +++ b/scripts/perf.py @@ -17,7 +17,7 @@ import errno import fcntl import functools as ft import itertools as it -import math as m +import math as mt import multiprocessing as mp import os import re @@ -49,24 +49,24 @@ class RInt(co.namedtuple('RInt', 'x')): except ValueError: # also accept +-∞ and +-inf if re.match('^\s*\+?\s*(?:∞|inf)\s*$', x): - x = m.inf + x = mt.inf elif re.match('^\s*-\s*(?:∞|inf)\s*$', x): - x = -m.inf + x = -mt.inf else: raise - assert isinstance(x, int) or m.isinf(x), x + assert isinstance(x, int) or mt.isinf(x), x return super().__new__(cls, x) def __str__(self): - if self.x == m.inf: + if self.x == mt.inf: return '∞' - elif self.x == -m.inf: + elif self.x == -mt.inf: return '-∞' else: return str(self.x) def __int__(self): - assert not m.isinf(self.x) + assert not mt.isinf(self.x) return self.x def __float__(self): @@ -80,9 +80,9 @@ class RInt(co.namedtuple('RInt', 'x')): new = self.x if self else 0 old = other.x if other else 0 diff = new - old - if diff == +m.inf: + if diff == +mt.inf: return '%7s' % '+∞' - elif diff == -m.inf: + elif diff == -mt.inf: return '%7s' % '-∞' else: return '%+7d' % diff @@ -90,16 +90,16 @@ class RInt(co.namedtuple('RInt', 'x')): def ratio(self, other): new = self.x if self else 0 old = other.x if other else 0 - if m.isinf(new) and m.isinf(old): + if mt.isinf(new) and mt.isinf(old): return 0.0 - elif m.isinf(new): - return +m.inf - elif m.isinf(old): - return -m.inf + elif mt.isinf(new): + return +mt.inf + elif mt.isinf(old): + return -mt.inf elif not old and not new: return 0.0 elif not old: - return +m.inf + return +mt.inf else: return (new-old) / old @@ -789,8 +789,8 @@ def table(Result, results, diff_results=None, *, (getattr(r, k).table() if getattr(r, k, None) is not None else types[k].none, - (lambda t: ['+∞%'] if t == +m.inf - else ['-∞%'] if t == -m.inf + (lambda t: ['+∞%'] if t == +mt.inf + else ['-∞%'] if t == -mt.inf else ['%+.1f%%' % (100*t)])( types[k].ratio( getattr(r, k, None), @@ -809,8 +809,8 @@ def table(Result, results, diff_results=None, *, (types[k].diff( getattr(r, k, None), getattr(diff_r, k, None)), - (lambda t: ['+∞%'] if t == +m.inf - else ['-∞%'] if t == -m.inf + (lambda t: ['+∞%'] if t == +mt.inf + else ['-∞%'] if t == -mt.inf else ['%+.1f%%' % (100*t)] if t else [])( types[k].ratio( @@ -1037,9 +1037,9 @@ def report(perf_paths, *, # figure out depth if args.get('depth') is None: - args['depth'] = m.inf if args.get('hot') else 1 + args['depth'] = mt.inf if args.get('hot') else 1 elif args.get('depth') == 0: - args['depth'] = m.inf + args['depth'] = mt.inf # find sizes if not args.get('use', None): diff --git a/scripts/perfbd.py b/scripts/perfbd.py index 13de25bc..3bc6e720 100755 --- a/scripts/perfbd.py +++ b/scripts/perfbd.py @@ -16,7 +16,7 @@ import collections as co import csv import functools as ft import itertools as it -import math as m +import math as mt import multiprocessing as mp import os import re @@ -40,24 +40,24 @@ class RInt(co.namedtuple('RInt', 'x')): except ValueError: # also accept +-∞ and +-inf if re.match('^\s*\+?\s*(?:∞|inf)\s*$', x): - x = m.inf + x = mt.inf elif re.match('^\s*-\s*(?:∞|inf)\s*$', x): - x = -m.inf + x = -mt.inf else: raise - assert isinstance(x, int) or m.isinf(x), x + assert isinstance(x, int) or mt.isinf(x), x return super().__new__(cls, x) def __str__(self): - if self.x == m.inf: + if self.x == mt.inf: return '∞' - elif self.x == -m.inf: + elif self.x == -mt.inf: return '-∞' else: return str(self.x) def __int__(self): - assert not m.isinf(self.x) + assert not mt.isinf(self.x) return self.x def __float__(self): @@ -71,9 +71,9 @@ class RInt(co.namedtuple('RInt', 'x')): new = self.x if self else 0 old = other.x if other else 0 diff = new - old - if diff == +m.inf: + if diff == +mt.inf: return '%7s' % '+∞' - elif diff == -m.inf: + elif diff == -mt.inf: return '%7s' % '-∞' else: return '%+7d' % diff @@ -81,16 +81,16 @@ class RInt(co.namedtuple('RInt', 'x')): def ratio(self, other): new = self.x if self else 0 old = other.x if other else 0 - if m.isinf(new) and m.isinf(old): + if mt.isinf(new) and mt.isinf(old): return 0.0 - elif m.isinf(new): - return +m.inf - elif m.isinf(old): - return -m.inf + elif mt.isinf(new): + return +mt.inf + elif mt.isinf(old): + return -mt.inf elif not old and not new: return 0.0 elif not old: - return +m.inf + return +mt.inf else: return (new-old) / old @@ -566,7 +566,7 @@ def collect(obj_path, trace_paths, *, trace_ranges.append([(None, None)]) continue - perjob = m.ceil(size // jobs) + perjob = mt.ceil(size // jobs) trace_ranges.append([(i, i+perjob) for i in range(0, size, perjob)]) results = [] @@ -753,8 +753,8 @@ def table(Result, results, diff_results=None, *, (getattr(r, k).table() if getattr(r, k, None) is not None else types[k].none, - (lambda t: ['+∞%'] if t == +m.inf - else ['-∞%'] if t == -m.inf + (lambda t: ['+∞%'] if t == +mt.inf + else ['-∞%'] if t == -mt.inf else ['%+.1f%%' % (100*t)])( types[k].ratio( getattr(r, k, None), @@ -773,8 +773,8 @@ def table(Result, results, diff_results=None, *, (types[k].diff( getattr(r, k, None), getattr(diff_r, k, None)), - (lambda t: ['+∞%'] if t == +m.inf - else ['-∞%'] if t == -m.inf + (lambda t: ['+∞%'] if t == +mt.inf + else ['-∞%'] if t == -mt.inf else ['%+.1f%%' % (100*t)] if t else [])( types[k].ratio( @@ -1015,9 +1015,9 @@ def report(obj_path='', trace_paths=[], *, # figure out depth if args.get('depth') is None: - args['depth'] = m.inf if args.get('hot') else 1 + args['depth'] = mt.inf if args.get('hot') else 1 elif args.get('depth') == 0: - args['depth'] = m.inf + args['depth'] = mt.inf # find sizes if not args.get('use', None): diff --git a/scripts/plot.py b/scripts/plot.py index 2adf3211..392f1806 100755 --- a/scripts/plot.py +++ b/scripts/plot.py @@ -15,7 +15,7 @@ import collections as co import csv import io import itertools as it -import math as m +import math as mt import os import shlex import shutil @@ -95,7 +95,7 @@ def si(x, w=4): # # note we adjust this so that 100K = .1M, which has more info # per character - p = 3*int(m.log(abs(x)*10, 10**3)) + p = 3*int(mt.log(abs(x)*10, 10**3)) p = min(18, max(-18, p)) # format with enough digits s = '%.*f' % (w, abs(x) / (10.0**p)) @@ -114,7 +114,7 @@ def si2(x, w=5): # # note we adjust this so that 128Ki = .1Mi, which has more info # per character - p = 10*int(m.log(abs(x)*10, 2**10)) + p = 10*int(mt.log(abs(x)*10, 2**10)) p = min(30, max(-30, p)) # format with enough digits s = '%.*f' % (w, abs(x) / (2.0**p)) @@ -258,7 +258,7 @@ def dat(x): try: return float(x) # just don't allow infinity or nan - if m.isinf(x) or m.isnan(x): + if mt.isinf(x) or mt.isnan(x): raise ValueError("invalid dat %r" % x) except ValueError: pass @@ -270,9 +270,9 @@ def dat(x): # a hack log that preserves sign, with a linear region between -1 and 1 def symlog(x): if x > 1: - return m.log(x)+1 + return mt.log(x)+1 elif x < -1: - return -m.log(-x)-1 + return -mt.log(-x)-1 else: return x @@ -614,9 +614,9 @@ class Grid: self_i = 0 other_i = 0 self_xweight = (self_xweights[self_i] - if self_i < len(self_xweights) else m.inf) + if self_i < len(self_xweights) else mt.inf) other_xweight = (other_xweights[other_i] - if other_i < len(other_xweights) else m.inf) + if other_i < len(other_xweights) else mt.inf) while self_i < len(self_xweights) and other_i < len(other_xweights): if other_xweight - self_xweight > 0.0000001: new_xweights.append(self_xweight) @@ -635,7 +635,7 @@ class Grid: self_i += 1 self_xweight = (self_xweights[self_i] - if self_i < len(self_xweights) else m.inf) + if self_i < len(self_xweights) else mt.inf) elif self_xweight - other_xweight > 0.0000001: new_xweights.append(other_xweight) self_xweight -= other_xweight @@ -653,7 +653,7 @@ class Grid: other_i += 1 other_xweight = (other_xweights[other_i] - if other_i < len(other_xweights) else m.inf) + if other_i < len(other_xweights) else mt.inf) else: new_xweights.append(self_xweight) @@ -665,10 +665,10 @@ class Grid: self_i += 1 self_xweight = (self_xweights[self_i] - if self_i < len(self_xweights) else m.inf) + if self_i < len(self_xweights) else mt.inf) other_i += 1 other_xweight = (other_xweights[other_i] - if other_i < len(other_xweights) else m.inf) + if other_i < len(other_xweights) else mt.inf) # squish so ratios are preserved self_h = sum(self.yweights) @@ -712,9 +712,9 @@ class Grid: self_i = 0 other_i = 0 self_yweight = (self_yweights[self_i] - if self_i < len(self_yweights) else m.inf) + if self_i < len(self_yweights) else mt.inf) other_yweight = (other_yweights[other_i] - if other_i < len(other_yweights) else m.inf) + if other_i < len(other_yweights) else mt.inf) while self_i < len(self_yweights) and other_i < len(other_yweights): if other_yweight - self_yweight > 0.0000001: new_yweights.append(self_yweight) @@ -733,7 +733,7 @@ class Grid: self_i += 1 self_yweight = (self_yweights[self_i] - if self_i < len(self_yweights) else m.inf) + if self_i < len(self_yweights) else mt.inf) elif self_yweight - other_yweight > 0.0000001: new_yweights.append(other_yweight) self_yweight -= other_yweight @@ -751,7 +751,7 @@ class Grid: other_i += 1 other_yweight = (other_yweights[other_i] - if other_i < len(other_yweights) else m.inf) + if other_i < len(other_yweights) else mt.inf) else: new_yweights.append(self_yweight) @@ -763,10 +763,10 @@ class Grid: self_i += 1 self_yweight = (self_yweights[self_i] - if self_i < len(self_yweights) else m.inf) + if self_i < len(self_yweights) else mt.inf) other_i += 1 other_yweight = (other_yweights[other_i] - if other_i < len(other_yweights) else m.inf) + if other_i < len(other_yweights) else mt.inf) # squish so ratios are preserved self_w = sum(self.xweights) @@ -1117,8 +1117,8 @@ def main(csv_paths, *, # exceeding the requested dimensions, this means we usually are less # than the requested dimensions by quite a bit when we have many # subplots, but it's a tradeoff for a relatively simple implementation - widths = [m.floor(w*width_) for w in grid.xweights] - heights = [m.floor(w*height_) for w in grid.yweights] + widths = [mt.floor(w*width_) for w in grid.xweights] + heights = [mt.floor(w*height_) for w in grid.yweights] # tweak dimensions to allow all plots to have a minimum width, # this may force the plot to be larger than the requested dimensions, diff --git a/scripts/plotmpl.py b/scripts/plotmpl.py index 19a963a8..923f12c7 100755 --- a/scripts/plotmpl.py +++ b/scripts/plotmpl.py @@ -15,7 +15,7 @@ import csv import io import itertools as it import logging -import math as m +import math as mt import numpy as np import os import shlex @@ -98,7 +98,7 @@ def si(x): if x == 0: return '0' # figure out prefix and scale - p = 3*int(m.log(abs(x), 10**3)) + p = 3*int(mt.log(abs(x), 10**3)) p = min(18, max(-18, p)) # format with 3 digits of precision s = '%.3f' % (abs(x) / (10.0**p)) @@ -114,7 +114,7 @@ def si2(x): if x == 0: return '0' # figure out prefix and scale - p = 10*int(m.log(abs(x), 2**10)) + p = 10*int(mt.log(abs(x), 2**10)) p = min(30, max(-30, p)) # format with 3 digits of precision s = '%.3f' % (abs(x) / (2.0**p)) @@ -148,7 +148,8 @@ class AutoMultipleLocator(mpl.ticker.MultipleLocator): nbins = np.clip(self.axis.get_tick_space(), 1, 9) # find the best power, use this as our locator's actual base - scale = self.base ** (m.ceil(m.log((vmax-vmin) / (nbins+1), self.base))) + scale = self.base + ** (mt.ceil(mt.log((vmax-vmin) / (nbins+1), self.base))) self.set_params(scale) return super().__call__() @@ -181,7 +182,7 @@ def dat(x): try: return float(x) # just don't allow infinity or nan - if m.isinf(x) or m.isnan(x): + if mt.isinf(x) or mt.isnan(x): raise ValueError("invalid dat %r" % x) except ValueError: pass @@ -352,9 +353,9 @@ class Grid: self_i = 0 other_i = 0 self_xweight = (self_xweights[self_i] - if self_i < len(self_xweights) else m.inf) + if self_i < len(self_xweights) else mt.inf) other_xweight = (other_xweights[other_i] - if other_i < len(other_xweights) else m.inf) + if other_i < len(other_xweights) else mt.inf) while self_i < len(self_xweights) and other_i < len(other_xweights): if other_xweight - self_xweight > 0.0000001: new_xweights.append(self_xweight) @@ -373,7 +374,7 @@ class Grid: self_i += 1 self_xweight = (self_xweights[self_i] - if self_i < len(self_xweights) else m.inf) + if self_i < len(self_xweights) else mt.inf) elif self_xweight - other_xweight > 0.0000001: new_xweights.append(other_xweight) self_xweight -= other_xweight @@ -391,7 +392,7 @@ class Grid: other_i += 1 other_xweight = (other_xweights[other_i] - if other_i < len(other_xweights) else m.inf) + if other_i < len(other_xweights) else mt.inf) else: new_xweights.append(self_xweight) @@ -403,10 +404,10 @@ class Grid: self_i += 1 self_xweight = (self_xweights[self_i] - if self_i < len(self_xweights) else m.inf) + if self_i < len(self_xweights) else mt.inf) other_i += 1 other_xweight = (other_xweights[other_i] - if other_i < len(other_xweights) else m.inf) + if other_i < len(other_xweights) else mt.inf) # squish so ratios are preserved self_h = sum(self.yweights) @@ -450,9 +451,9 @@ class Grid: self_i = 0 other_i = 0 self_yweight = (self_yweights[self_i] - if self_i < len(self_yweights) else m.inf) + if self_i < len(self_yweights) else mt.inf) other_yweight = (other_yweights[other_i] - if other_i < len(other_yweights) else m.inf) + if other_i < len(other_yweights) else mt.inf) while self_i < len(self_yweights) and other_i < len(other_yweights): if other_yweight - self_yweight > 0.0000001: new_yweights.append(self_yweight) @@ -471,7 +472,7 @@ class Grid: self_i += 1 self_yweight = (self_yweights[self_i] - if self_i < len(self_yweights) else m.inf) + if self_i < len(self_yweights) else mt.inf) elif self_yweight - other_yweight > 0.0000001: new_yweights.append(other_yweight) self_yweight -= other_yweight @@ -489,7 +490,7 @@ class Grid: other_i += 1 other_yweight = (other_yweights[other_i] - if other_i < len(other_yweights) else m.inf) + if other_i < len(other_yweights) else mt.inf) else: new_yweights.append(self_yweight) @@ -501,10 +502,10 @@ class Grid: self_i += 1 self_yweight = (self_yweights[self_i] - if self_i < len(self_yweights) else m.inf) + if self_i < len(self_yweights) else mt.inf) other_i += 1 other_yweight = (other_yweights[other_i] - if other_i < len(other_yweights) else m.inf) + if other_i < len(other_yweights) else mt.inf) # squish so ratios are preserved self_w = sum(self.xweights) @@ -978,7 +979,7 @@ def main(csv_paths, output, *, # try different column counts until we fit in the axes for ncol in reversed(range(1, len(legend)+1)): # permute the labels, mpl wants to order these column first - nrow = m.ceil(len(legend)/ncol) + nrow = mt.ceil(len(legend)/ncol) legend_ = ncol*nrow*[None] for x in range(ncol): for y in range(nrow): @@ -1012,7 +1013,7 @@ def main(csv_paths, output, *, # try different column counts until we fit in the axes for ncol in reversed(range(1, len(legend)+1)): # permute the labels, mpl wants to order these column first - nrow = m.ceil(len(legend)/ncol) + nrow = mt.ceil(len(legend)/ncol) legend_ = ncol*nrow*[None] for x in range(ncol): for y in range(nrow): diff --git a/scripts/stack.py b/scripts/stack.py index cfd04dd8..9b501276 100755 --- a/scripts/stack.py +++ b/scripts/stack.py @@ -13,7 +13,7 @@ import collections as co import csv import itertools as it -import math as m +import math as mt import os import re @@ -31,24 +31,24 @@ class RInt(co.namedtuple('RInt', 'x')): except ValueError: # also accept +-∞ and +-inf if re.match('^\s*\+?\s*(?:∞|inf)\s*$', x): - x = m.inf + x = mt.inf elif re.match('^\s*-\s*(?:∞|inf)\s*$', x): - x = -m.inf + x = -mt.inf else: raise - assert isinstance(x, int) or m.isinf(x), x + assert isinstance(x, int) or mt.isinf(x), x return super().__new__(cls, x) def __str__(self): - if self.x == m.inf: + if self.x == mt.inf: return '∞' - elif self.x == -m.inf: + elif self.x == -mt.inf: return '-∞' else: return str(self.x) def __int__(self): - assert not m.isinf(self.x) + assert not mt.isinf(self.x) return self.x def __float__(self): @@ -62,9 +62,9 @@ class RInt(co.namedtuple('RInt', 'x')): new = self.x if self else 0 old = other.x if other else 0 diff = new - old - if diff == +m.inf: + if diff == +mt.inf: return '%7s' % '+∞' - elif diff == -m.inf: + elif diff == -mt.inf: return '%7s' % '-∞' else: return '%+7d' % diff @@ -72,16 +72,16 @@ class RInt(co.namedtuple('RInt', 'x')): def ratio(self, other): new = self.x if self else 0 old = other.x if other else 0 - if m.isinf(new) and m.isinf(old): + if mt.isinf(new) and mt.isinf(old): return 0.0 - elif m.isinf(new): - return +m.inf - elif m.isinf(old): - return -m.inf + elif mt.isinf(new): + return +mt.inf + elif mt.isinf(old): + return -mt.inf elif not old and not new: return 0.0 elif not old: - return +m.inf + return +mt.inf else: return (new-old) / old @@ -251,7 +251,7 @@ def collect(ci_paths, *, for target in targets: # found a cycle? if target in seen: - return m.inf + return mt.inf limit_ = find_limit(target, seen | {target}) limit = max(limit, limit_) @@ -438,8 +438,8 @@ def table(Result, results, diff_results=None, *, (getattr(r, k).table() if getattr(r, k, None) is not None else types[k].none, - (lambda t: ['+∞%'] if t == +m.inf - else ['-∞%'] if t == -m.inf + (lambda t: ['+∞%'] if t == +mt.inf + else ['-∞%'] if t == -mt.inf else ['%+.1f%%' % (100*t)])( types[k].ratio( getattr(r, k, None), @@ -458,8 +458,8 @@ def table(Result, results, diff_results=None, *, (types[k].diff( getattr(r, k, None), getattr(diff_r, k, None)), - (lambda t: ['+∞%'] if t == +m.inf - else ['-∞%'] if t == -m.inf + (lambda t: ['+∞%'] if t == +mt.inf + else ['-∞%'] if t == -mt.inf else ['%+.1f%%' % (100*t)] if t else [])( types[k].ratio( @@ -579,9 +579,9 @@ def main(ci_paths, **args): # figure out depth if args.get('depth') is None: - args['depth'] = m.inf if args.get('hot') else 1 + args['depth'] = mt.inf if args.get('hot') else 1 elif args.get('depth') == 0: - args['depth'] = m.inf + args['depth'] = mt.inf # find sizes if not args.get('use', None): @@ -674,7 +674,7 @@ def main(ci_paths, # error on recursion if args.get('error_on_recursion') and any( - m.isinf(float(r.limit)) for r in results): + mt.isinf(float(r.limit)) for r in results): sys.exit(2) diff --git a/scripts/structs.py b/scripts/structs.py index 3d2a9e7f..c70d4325 100755 --- a/scripts/structs.py +++ b/scripts/structs.py @@ -13,7 +13,7 @@ import collections as co import csv import difflib import itertools as it -import math as m +import math as mt import os import re import shlex @@ -36,24 +36,24 @@ class RInt(co.namedtuple('RInt', 'x')): except ValueError: # also accept +-∞ and +-inf if re.match('^\s*\+?\s*(?:∞|inf)\s*$', x): - x = m.inf + x = mt.inf elif re.match('^\s*-\s*(?:∞|inf)\s*$', x): - x = -m.inf + x = -mt.inf else: raise - assert isinstance(x, int) or m.isinf(x), x + assert isinstance(x, int) or mt.isinf(x), x return super().__new__(cls, x) def __str__(self): - if self.x == m.inf: + if self.x == mt.inf: return '∞' - elif self.x == -m.inf: + elif self.x == -mt.inf: return '-∞' else: return str(self.x) def __int__(self): - assert not m.isinf(self.x) + assert not mt.isinf(self.x) return self.x def __float__(self): @@ -67,9 +67,9 @@ class RInt(co.namedtuple('RInt', 'x')): new = self.x if self else 0 old = other.x if other else 0 diff = new - old - if diff == +m.inf: + if diff == +mt.inf: return '%7s' % '+∞' - elif diff == -m.inf: + elif diff == -mt.inf: return '%7s' % '-∞' else: return '%+7d' % diff @@ -77,16 +77,16 @@ class RInt(co.namedtuple('RInt', 'x')): def ratio(self, other): new = self.x if self else 0 old = other.x if other else 0 - if m.isinf(new) and m.isinf(old): + if mt.isinf(new) and mt.isinf(old): return 0.0 - elif m.isinf(new): - return +m.inf - elif m.isinf(old): - return -m.inf + elif mt.isinf(new): + return +mt.inf + elif mt.isinf(old): + return -mt.inf elif not old and not new: return 0.0 elif not old: - return +m.inf + return +mt.inf else: return (new-old) / old @@ -395,8 +395,8 @@ def table(Result, results, diff_results=None, *, (getattr(r, k).table() if getattr(r, k, None) is not None else types[k].none, - (lambda t: ['+∞%'] if t == +m.inf - else ['-∞%'] if t == -m.inf + (lambda t: ['+∞%'] if t == +mt.inf + else ['-∞%'] if t == -mt.inf else ['%+.1f%%' % (100*t)])( types[k].ratio( getattr(r, k, None), @@ -415,8 +415,8 @@ def table(Result, results, diff_results=None, *, (types[k].diff( getattr(r, k, None), getattr(diff_r, k, None)), - (lambda t: ['+∞%'] if t == +m.inf - else ['-∞%'] if t == -m.inf + (lambda t: ['+∞%'] if t == +mt.inf + else ['-∞%'] if t == -mt.inf else ['%+.1f%%' % (100*t)] if t else [])( types[k].ratio( diff --git a/scripts/summary.py b/scripts/summary.py index fd48f7eb..009e5e11 100755 --- a/scripts/summary.py +++ b/scripts/summary.py @@ -16,7 +16,7 @@ import collections as co import csv import functools as ft import itertools as it -import math as m +import math as mt import os import re @@ -27,20 +27,22 @@ import re # OPS = { 'sum': lambda xs: sum(xs[1:], start=xs[0]), - 'prod': lambda xs: m.prod(xs[1:], start=xs[0]), + 'prod': lambda xs: mt.prod(xs[1:], start=xs[0]), 'min': min, 'max': max, 'avg': lambda xs: RFloat(sum(float(x) for x in xs) / len(xs)), 'stddev': lambda xs: ( lambda avg: RFloat( - m.sqrt(sum((float(x) - avg)**2 for x in xs) / len(xs))) + mt.sqrt(sum((float(x) - avg)**2 for x in xs) / len(xs))) )(sum(float(x) for x in xs) / len(xs)), - 'gmean': lambda xs: RFloat(m.prod(float(x) for x in xs)**(1/len(xs))), + 'gmean': lambda xs: RFloat(mt.prod(float(x) for x in xs)**(1/len(xs))), 'gstddev': lambda xs: ( lambda gmean: RFloat( - m.exp(m.sqrt(sum(m.log(float(x)/gmean)**2 for x in xs) / len(xs))) - if gmean else m.inf) - )(m.prod(float(x) for x in xs)**(1/len(xs))), + mt.exp(mt.sqrt( + sum(mt.log(float(x)/gmean)**2 for x in xs) + / len(xs))) + if gmean else mt.inf) + )(mt.prod(float(x) for x in xs)**(1/len(xs))), } @@ -56,24 +58,24 @@ class RInt(co.namedtuple('RInt', 'x')): except ValueError: # also accept +-∞ and +-inf if re.match('^\s*\+?\s*(?:∞|inf)\s*$', x): - x = m.inf + x = mt.inf elif re.match('^\s*-\s*(?:∞|inf)\s*$', x): - x = -m.inf + x = -mt.inf else: raise - assert isinstance(x, int) or m.isinf(x), x + assert isinstance(x, int) or mt.isinf(x), x return super().__new__(cls, x) def __str__(self): - if self.x == m.inf: + if self.x == mt.inf: return '∞' - elif self.x == -m.inf: + elif self.x == -mt.inf: return '-∞' else: return str(self.x) def __int__(self): - assert not m.isinf(self.x) + assert not mt.isinf(self.x) return self.x def __float__(self): @@ -87,9 +89,9 @@ class RInt(co.namedtuple('RInt', 'x')): new = self.x if self else 0 old = other.x if other else 0 diff = new - old - if diff == +m.inf: + if diff == +mt.inf: return '%7s' % '+∞' - elif diff == -m.inf: + elif diff == -mt.inf: return '%7s' % '-∞' else: return '%+7d' % diff @@ -97,16 +99,16 @@ class RInt(co.namedtuple('RInt', 'x')): def ratio(self, other): new = self.x if self else 0 old = other.x if other else 0 - if m.isinf(new) and m.isinf(old): + if mt.isinf(new) and mt.isinf(old): return 0.0 - elif m.isinf(new): - return +m.inf - elif m.isinf(old): - return -m.inf + elif mt.isinf(new): + return +mt.inf + elif mt.isinf(old): + return -mt.inf elif not old and not new: return 0.0 elif not old: - return +m.inf + return +mt.inf else: return (new-old) / old @@ -131,18 +133,18 @@ class RFloat(co.namedtuple('RFloat', 'x')): except ValueError: # also accept +-∞ and +-inf if re.match('^\s*\+?\s*(?:∞|inf)\s*$', x): - x = m.inf + x = mt.inf elif re.match('^\s*-\s*(?:∞|inf)\s*$', x): - x = -m.inf + x = -mt.inf else: raise assert isinstance(x, float), x return super().__new__(cls, x) def __str__(self): - if self.x == m.inf: + if self.x == mt.inf: return '∞' - elif self.x == -m.inf: + elif self.x == -mt.inf: return '-∞' else: return '%.1f' % self.x @@ -157,9 +159,9 @@ class RFloat(co.namedtuple('RFloat', 'x')): new = self.x if self else 0 old = other.x if other else 0 diff = new - old - if diff == +m.inf: + if diff == +mt.inf: return '%7s' % '+∞' - elif diff == -m.inf: + elif diff == -mt.inf: return '%7s' % '-∞' else: return '%+7.1f' % diff @@ -193,8 +195,8 @@ class RFrac(co.namedtuple('RFrac', 'a,b')): def notes(self): t = self.a.x/self.b.x if self.b.x else 1.0 - return ['∞%' if t == +m.inf - else '-∞%' if t == -m.inf + return ['∞%' if t == +mt.inf + else '-∞%' if t == -mt.inf else '%.1f%%' % (100*t)] def diff(self, other): @@ -526,8 +528,8 @@ def table(Result, results, diff_results=None, *, (getattr(r, k).table() if getattr(r, k, None) is not None else types[k].none, - (lambda t: ['+∞%'] if t == +m.inf - else ['-∞%'] if t == -m.inf + (lambda t: ['+∞%'] if t == +mt.inf + else ['-∞%'] if t == -mt.inf else ['%+.1f%%' % (100*t)])( types[k].ratio( getattr(r, k, None), @@ -546,8 +548,8 @@ def table(Result, results, diff_results=None, *, (types[k].diff( getattr(r, k, None), getattr(diff_r, k, None)), - (lambda t: ['+∞%'] if t == +m.inf - else ['-∞%'] if t == -m.inf + (lambda t: ['+∞%'] if t == +mt.inf + else ['-∞%'] if t == -mt.inf else ['%+.1f%%' % (100*t)] if t else [])( types[k].ratio( diff --git a/scripts/test.py b/scripts/test.py index 896826fd..9c07c2f1 100755 --- a/scripts/test.py +++ b/scripts/test.py @@ -14,7 +14,7 @@ import csv import errno import fnmatch import itertools as it -import math as m +import math as mt import os import pty import re diff --git a/scripts/tracebd.py b/scripts/tracebd.py index a2247910..be7c08db 100755 --- a/scripts/tracebd.py +++ b/scripts/tracebd.py @@ -13,7 +13,7 @@ import collections as co import functools as ft import io import itertools as it -import math as m +import math as mt import os import re import shutil @@ -257,9 +257,9 @@ def lebesgue_curve(width, height): # we create a truncated Z-curve by simply filtering out the points # that are outside our region curve = [] - for i in range(2**(2*m.ceil(m.log2(max(width, height))))): + for i in range(2**(2*mt.ceil(mt.log2(max(width, height))))): # we just operate on binary strings here because it's easier - b = '{:0{}b}'.format(i, 2*m.ceil(m.log2(i+1)/2)) + b = '{:0{}b}'.format(i, 2*mt.ceil(mt.log2(i+1)/2)) x = int(b[1::2], 2) if b[1::2] else 0 y = int(b[0::2], 2) if b[0::2] else 0 if x < width and y < height: @@ -935,8 +935,8 @@ def main(path='-', *, # don't forget we've scaled this for braille/dots! for row in range( - m.ceil(bmap.height/4) if braille - else m.ceil(bmap.height/2) if dots + mt.ceil(bmap.height/4) if braille + else mt.ceil(bmap.height/2) if dots else bmap.height): line = bmap.draw(row, read=read, @@ -966,7 +966,7 @@ def main(path='-', *, if wear: mean = (sum(p.wear for p in bmap.pixels) / max(len(bmap.pixels), 1)) - stddev = m.sqrt(sum((p.wear - mean)**2 for p in bmap.pixels) + stddev = mt.sqrt(sum((p.wear - mean)**2 for p in bmap.pixels) / max(len(bmap.pixels), 1)) worst = max((p.wear for p in bmap.pixels), default=0)