Function
format_float
(num, total_width=20, decimal_places=12)
Source from the content-addressed store, hash-verified
| 62 | |
| 63 | def format_matrix_str(matrix): |
| 64 | def format_float(num, total_width=20, decimal_places=12): |
| 65 | # strip all right 0s, then strip '.' |
| 66 | s = f"{num:{total_width}.{decimal_places}f}".rstrip("0").rstrip(".") |
| 67 | # add space to the left |
| 68 | return f"{s:>{total_width}}" |
| 69 | formatted = [ |
| 70 | [ |
| 71 | # f"{num:20.12f}".rstrip("0").rstrip(".") if "." in f"{num}" else f"{num:20}" |
Tested by
no test coverage detected