randomcolor-py icon indicating copy to clipboard operation
randomcolor-py copied to clipboard

same seed produces different colors

Open berleant opened this issue 5 years ago • 2 comments

~~I only observed this behavior in python 3, not python 2.~~ This is for python versions prior to 3.7. See comments below. Using this script generate.py:

import randomcolor
import sys
rand_color = randomcolor.RandomColor(int(sys.argv[1]))
colors = rand_color.generate(count=250)
for i, color in enumerate(colors):
    print(i, color)

Run the following commands:

$ python generate.py 50 > run1
$ python generate.py 50 > run2
$ python generate.py 50 > run3
$ diff run1 run2
$ diff run1 run3
140c140
< 139 #f7b7b8
---
> 139 #514c4c

berleant avatar May 13 '20 23:05 berleant

I don't see this issue with Python 3.8.5. My diffs are empty.

christian-rauch avatar Jan 27 '21 10:01 christian-rauch

It appears that as of python 3.7, this should not be a problem. See my PR--the problem was that the order of dictionary keys is not guaranteed prior to version 3.7 (https://docs.python.org/3.7/whatsnew/3.7.html). Pre-3.7, however, it might still be a problem depending on implementation.

berleant avatar Apr 18 '21 16:04 berleant