Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
SimStadt
simstadtpy
Commits
4bad3f78
You need to sign in or sign up before continuing.
Commit
4bad3f78
authored
Mar 13, 2026
by
Eric Duminil
Browse files
Unused utils
parent
140dd6ae
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/simstadt/utils.py
View file @
4bad3f78
...
@@ -5,7 +5,6 @@ import random
...
@@ -5,7 +5,6 @@ import random
import
re
import
re
import
string
import
string
from
contextlib
import
contextmanager
from
contextlib
import
contextmanager
from
math
import
floor
,
log10
from
pathlib
import
Path
from
pathlib
import
Path
import
numpy
as
np
import
numpy
as
np
...
@@ -13,26 +12,6 @@ import numpy as np
...
@@ -13,26 +12,6 @@ import numpy as np
log
=
logging
.
getLogger
(
__name__
)
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
:
def
set_random_seed
(
input_string
:
str
)
->
None
:
"""Seed both random and numpy from a string so sampling is reproducible between runs."""
"""Seed both random and numpy from a string so sampling is reproducible between runs."""
random
.
seed
(
input_string
)
random
.
seed
(
input_string
)
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment