Skip to content

Commit

Permalink
revert change to global seed
Browse files Browse the repository at this point in the history
  • Loading branch information
Dan King committed Jan 31, 2023
1 parent 5b737d2 commit daae1d3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
5 changes: 2 additions & 3 deletions hail/python/hail/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,11 +116,10 @@ def __init__(self, log, quiet, append, tmpdir, local_tmpdir, global_seed, backen
' the latest changes weekly.\n')
sys.stderr.write(f'LOGGING: writing to {log}\n')

self._user_specified_rng_nonce = True
if global_seed is None:
self._user_specified_rng_nonce = False
backend.set_flags(rng_nonce=str(Random().randrange(-2**63, 2**63 - 1)))
backend.set_flags(rng_nonce=str(0))
else:
self._user_specified_rng_nonce = True
backend.set_flags(rng_nonce=str(global_seed))
Env._hc = self

Expand Down
16 changes: 8 additions & 8 deletions hail/python/test/hail/test_randomness.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,16 +64,16 @@ def test_matrix_table_entries():
mt = hl.utils.range_matrix_table(5, 2)
mt = mt.annotate_entries(x = hl.rand_int32(5))
expected = [
hl.Struct(row_idx=0, col_idx=0, x=1),
hl.Struct(row_idx=0, col_idx=1, x=2),
hl.Struct(row_idx=0, col_idx=0, x=0),
hl.Struct(row_idx=0, col_idx=1, x=3),
hl.Struct(row_idx=1, col_idx=0, x=2),
hl.Struct(row_idx=1, col_idx=1, x=3),
hl.Struct(row_idx=2, col_idx=0, x=0),
hl.Struct(row_idx=1, col_idx=1, x=4),
hl.Struct(row_idx=2, col_idx=0, x=1),
hl.Struct(row_idx=2, col_idx=1, x=4),
hl.Struct(row_idx=3, col_idx=0, x=3),
hl.Struct(row_idx=3, col_idx=1, x=0),
hl.Struct(row_idx=3, col_idx=0, x=4),
hl.Struct(row_idx=3, col_idx=1, x=2),
hl.Struct(row_idx=4, col_idx=0, x=4),
hl.Struct(row_idx=4, col_idx=1, x=3)
hl.Struct(row_idx=4, col_idx=1, x=4),
]
actual = mt.entries().collect()
assert expected == actual
Expand All @@ -84,7 +84,7 @@ def test_table_filter():
ht = hl.utils.range_table(5)
ht = ht.annotate(x = hl.rand_int32(5))
ht = ht.filter(ht.x % 3 == 0)
expected = [hl.Struct(idx=2, x=3)]
expected = [hl.Struct(idx=1, x=3), hl.Struct(idx=3, x=3), hl.Struct(idx=4, x=3)]
actual = ht.collect()
assert expected == actual

Expand Down

0 comments on commit daae1d3

Please sign in to comment.