From 19cbc3e1822fd6d7cd79bc38c0d573eefcfd04d4 Mon Sep 17 00:00:00 2001 From: Martin Bauer <martin.bauer@fau.de> Date: Thu, 1 Aug 2019 16:53:29 +0200 Subject: [PATCH] Fix RNG: use different key for each call otherwise all random numbers drawn for one cell are equal --- pystencils/rng.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pystencils/rng.py b/pystencils/rng.py index 26a92b313..91cccaeef 100644 --- a/pystencils/rng.py +++ b/pystencils/rng.py @@ -118,8 +118,12 @@ class PhiloxFourFloats(CustomCodeNode): def random_symbol(assignment_list, rng_node=PhiloxTwoDoubles, *args, **kwargs): + if 'keys' not in kwargs: + kwargs['keys'] = (0, 0) + while True: node = rng_node(*args, **kwargs) + kwargs['keys'] = (kwargs['keys'][0] + 1, kwargs['keys'][1]) inserted = False for symbol in node.result_symbols: if not inserted: -- GitLab