randomcolor-py
randomcolor-py copied to clipboard
same seed produces different colors
~~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
I don't see this issue with Python 3.8.5. My diffs are empty.
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.