Line | |
---|
1 | """ |
---|
2 | A few commonly needed functions. |
---|
3 | |
---|
4 | Backwards compatibility for direct imports. |
---|
5 | |
---|
6 | Ported to Python 3. |
---|
7 | """ |
---|
8 | |
---|
9 | # The API importers expect: |
---|
10 | from 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: |
---|
14 | def 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.