mirror of
https://github.com/Chia-Network/chia-blockchain.git
synced 2026-08-28 18:14:19 -05:00
21 lines
456 B
Python
21 lines
456 B
Python
# Package: utils
|
|
|
|
from __future__ import annotations
|
|
|
|
|
|
def clamp(n: int, smallest: int, largest: int) -> int:
|
|
return max(smallest, min(n, largest))
|
|
|
|
|
|
def make_monotonically_decreasing(seq: list[float]) -> list[float]:
|
|
out: list[float] = []
|
|
if len(seq) > 0:
|
|
min = seq[0]
|
|
for n in seq:
|
|
if n <= min:
|
|
out.append(n)
|
|
min = n
|
|
else:
|
|
out.append(min)
|
|
return out
|