Commit 4bad3f78 authored by Eric Duminil's avatar Eric Duminil
Browse files

Unused utils

parent 140dd6ae
......@@ -5,7 +5,6 @@ import random
import re
import string
from contextlib import contextmanager
from math import floor, log10
from pathlib import Path
import numpy as np
......@@ -13,26 +12,6 @@ import numpy as np
log = logging.getLogger(__name__)
def significant_digits(value: float, sig_digits: int = 4) -> float:
"""Round a number to a chosen number of significant digits."""
if value == 0:
return 0
order = floor(log10(abs(value)))
digits_after_point = sig_digits - order - 1
return round(value, digits_after_point)
def format_number(value, decimal_sep=",", thousand_sep=" "):
"""Format a number with thousand/decimal separators, removing trailing zeros."""
if value is None:
return ""
if not isinstance(value, (int, float)):
return value
return (
f"{value:,f}".rstrip("0").rstrip(".").replace(",", "X").replace(".", decimal_sep).replace("X", thousand_sep)
)
def set_random_seed(input_string: str) -> None:
"""Seed both random and numpy from a string so sampling is reproducible between runs."""
random.seed(input_string)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment