mirror of
https://github.com/vincentbernat/i3wm-configuration.git
synced 2025-08-07 11:44:48 +02:00
wallpaper: avoid underflow when computing weights
This commit is contained in:
parent
4924483665
commit
9d9b95b201
1 changed files with 2 additions and 1 deletions
|
@ -218,7 +218,8 @@ def get_random_images(directory: str, number: int) -> list[Image]:
|
||||||
except (OSError, ValueError):
|
except (OSError, ValueError):
|
||||||
count = 0
|
count = 0
|
||||||
counts.append(count)
|
counts.append(count)
|
||||||
weights = [1 / (count + 1) for count in counts]
|
counts = [count - min(counts) for count in counts]
|
||||||
|
weights = [100 / (count + 1) for count in counts]
|
||||||
images = [
|
images = [
|
||||||
PIL.Image.open(image)
|
PIL.Image.open(image)
|
||||||
for image in random.choices(image_files, k=number, weights=weights)
|
for image in random.choices(image_files, k=number, weights=weights)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue