source: trunk/src/allmydata/util/mathutil.py

Last change on this file was 1cfe843d, checked in by Alexandre Detiste <alexandre.detiste@…>, at 2024-02-22T23:40:25Z

more python2 removal

  • Property mode set to 100644
File size: 530 bytes
Line 
1"""
2A few commonly needed functions.
3
4Backwards compatibility for direct imports.
5
6Ported to Python 3.
7"""
8
9# The API importers expect:
10from pyutil.mathutil import div_ceil, next_multiple, pad_size, is_power_of_k, next_power_of_k, ave, log_ceil, log_floor
11
12
13# This function is not present in pyutil.mathutil:
14def round_sigfigs(f, n):
15    fmt = "%." + str(n-1) + "e"
16    return float(fmt % f)
17
18__all__ = ["div_ceil", "next_multiple", "pad_size", "is_power_of_k", "next_power_of_k", "ave", "log_ceil", "log_floor", "round_sigfigs"]
Note: See TracBrowser for help on using the repository browser.