Skip to content

Commit 44655cc

Browse files
Merge pull request #739 from tfaod/patch-2
[fix] random_utils.py to `_signed_to_unsigned`
2 parents bb7a566 + 5c4485e commit 44655cc

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

algorithmic_efficiency/random_utils.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,11 @@
2626

2727
def _signed_to_unsigned(seed: SeedType) -> SeedType:
2828
if isinstance(seed, int):
29-
return seed + 2**32 if seed < 0 else seed
29+
return seed % 2**32
3030
if isinstance(seed, list):
31-
return [s + 2**32 if s < 0 else s for s in seed]
31+
return [s % 2**32 for s in seed]
3232
if isinstance(seed, np.ndarray):
33-
return np.array([s + 2**32 if s < 0 else s for s in seed.tolist()])
33+
return np.array([s % 2**32 for s in seed.tolist()])
3434

3535

3636
def _fold_in(seed: SeedType, data: Any) -> List[Union[SeedType, Any]]:

0 commit comments

Comments
 (0)