master > master: src - clean up

- enums für Alphabete
- button layout
- refresh Knopf
- aspect ratio
This commit is contained in:
RD
2022-10-22 09:15:34 +02:00
parent 56744bd389
commit 1d627623c7
5 changed files with 142 additions and 39 deletions

View File

@@ -9,6 +9,29 @@ from fractions import Fraction;
import math;
import numpy as np;
import random;
from typing import TypeVar;
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# MODIFICATIONS
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# local usage only
T = TypeVar('T');
def sample(
X: list[T],
size: int = 1,
replace: bool = True,
) -> list[T]:
'''
@inputs
- `X` - a list
- `size` <int> - desired sample size
- `replace` <bool> - optional replacement
@returns a sample from an uniformly distributed set.
'''
return np.random.choice(X, size=size, replace=replace).tolist();
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# EXPORTS
@@ -19,4 +42,5 @@ __all__ = [
'math',
'np',
'random',
'sample',
];