lcompilers / lpython

Python compiler
https://lpython.org/
Other
1.47k stars 157 forks source link

refine testcase for random #2543

Closed syheliel closed 5 months ago

syheliel commented 5 months ago

Fix issue #2542 . test the distribution of random. The error rate is lower than 0.1% (tested locally 1000 times without fail)

certik commented 5 months ago

For me the random number seed is always the same, so I get always the same answer.

The test works fine, but we need to ensure the random seed is initialized using the system clock at the beginning of the program. That's a separate issue.

The test itself is good. If it ever fails, we can relax the 5% deviation to a higher number. Thanks!

certik commented 5 months ago

While playing with this code, I discovered two bugs:

The second one is just a bug in LPython. The first one however is a bug in the random seed initialization. We need to fix it.