(S, ng_sample_decay=1.0)
| 240 | |
| 241 | |
| 242 | def split_integer_exp_decay(S, ng_sample_decay=1.0): |
| 243 | if ng_sample_decay == 1.0: |
| 244 | N = random.randint(1, S) |
| 245 | else: |
| 246 | base = (1 - ng_sample_decay) / (1 - math.pow(ng_sample_decay, S)) |
| 247 | p = [base * math.pow(ng_sample_decay, i) for i in range(S)] |
| 248 | N = random.choices(list(range(1, S + 1)), p, k=1)[0] |
| 249 | cumsum = [0] + sorted(random.sample(range(1, S), N - 1)) + [S] |
| 250 | result = [cumsum[i+1] - cumsum[i] for i in range(len(cumsum) - 1)] |
| 251 | return result, cumsum |
| 252 | |
| 253 | |
| 254 | def pil_img2rgb(image): |
nothing calls this directly
no outgoing calls
no test coverage detected