def main():
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument('degree', type=int)
parser.add_argument('prec', type=int, default=50)
parser.add_argument('data', help="""Data of matrix to compute exp of. Should
be in scipy sparse csr format.""")
parser.add_argument('time', type=float)
parser.add_argument('--expr', type=lambda e: sympify(e, locals=globals()), help="""Precomputed CRAM
expression. Should have the same prec as 'prec'. If not provided, will be
computed from scratch.""")
parser.add_argument('--log-level', default=None, choices=['debug', 'info',
'warning', 'error', 'critical'])
# TODO: Add options for arguments to pass to various functions as needed.
try:
import argcomplete
argcomplete.autocomplete(parser)
except ImportError:
pass
args = parser.parse_args()
if args.log_level:
logger.setLevel(getattr(logging, args.log_level.upper()))
res = run_transmute_test(args.data, args.degree, args.prec,
args.time,expr=args.expr, _print=True)
print("Column sums (min, max):")
errors = {}
colsums = {}
for r in sorted(res):
if res[r] is None:
print('Could not compute', r)
continue
colsums[r] = np.sum(res[r], axis=1)
errors[r] = np.max(colsums[r]) - np.min(colsums[r])
for r in sorted(errors, key=lambda i:errors[i], reverse=True):
print(r, np.min(colsums[r]), np.max(colsums[r]))
评论列表
文章目录