Skip to content

Commit

Permalink
Merge pull request #764 from dirac-institute/rng_readability
Browse files Browse the repository at this point in the history
Small change to getModuleRNG for readability
  • Loading branch information
jeremykubica authored Jan 5, 2024
2 parents b58fba3 + 76ef564 commit 0d681a8
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion demo/test_bench.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
debug = False
if debug:
runLSSTSimulation(cmd_args_dict, configs)
else: # benchmark
else: # benchmark
cProfile.run("runLSSTSimulation(cmd_args_dict, configs)", "./tests/out/restats")

p = pstats.Stats("./tests/out/restats")
Expand Down
3 changes: 2 additions & 1 deletion src/sorcha/modules/PPModuleRNG.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ def getModuleRNG(self, module_name):
if module_name in self._rngs:
return self._rngs[module_name]

seed_offset = int(hashlib.md5(module_name.encode("utf-8")).hexdigest(), 16)
hashed_name = hashlib.md5(module_name.encode())
seed_offset = int(hashed_name.hexdigest(), base=16)
module_seed = (self._base_seed + seed_offset) % (2**31)
new_rng = np.random.default_rng(module_seed)
self._rngs[module_name] = new_rng
Expand Down

0 comments on commit 0d681a8

Please sign in to comment.