| Conditions | 3 |
| Total Lines | 13 |
| Code Lines | 7 |
| Lines | 13 |
| Ratio | 100 % |
| Changes | 0 | ||
| 1 | # Author: Simon Blanke |
||
| 9 | View Code Duplication | def set_random_seed(nth_process, random_state): |
|
|
|
|||
| 10 | """ |
||
| 11 | Sets the random seed separately for each thread |
||
| 12 | (to avoid getting the same results in each thread) |
||
| 13 | """ |
||
| 14 | if nth_process is None: |
||
| 15 | nth_process = 0 |
||
| 16 | |||
| 17 | if random_state is None: |
||
| 18 | random_state = np.random.randint(0, high=2 ** 31 - 2, dtype=np.int64) |
||
| 19 | |||
| 20 | random.seed(random_state + nth_process) |
||
| 21 | np.random.seed(random_state + nth_process) |
||
| 22 | |||
| 31 |