Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix random.random() #2464

Merged
merged 4 commits into from
Jan 26, 2024
Merged

Fix random.random() #2464

merged 4 commits into from
Jan 26, 2024

Conversation

Shaikh-Ubaid
Copy link
Collaborator

fixes #2382

@Shaikh-Ubaid
Copy link
Collaborator Author

Related PR lfortran/lfortran#3156

A Test is added in the related PR.

Also manual test:

% cat examples/expr2.py 
from lpython import f64
import random

def test_seed():
    random.seed()
    t1: f64 = random.random()
    print(t1)

test_seed()
% lpython examples/expr2.py
1.80525214961043207e-01
% lpython examples/expr2.py
8.56492263663789360e-02
% lpython examples/expr2.py
6.91035861936880158e-01
% lpython examples/expr2.py
6.65666734644056679e-01
% lpython examples/expr2.py
6.16492530618092283e-01
% lpython examples/expr2.py
2.97986548067064261e-01
% lpython examples/expr2.py
4.91210944713657227e-01
% lpython examples/expr2.py
8.56492263663789360e-02
% lpython examples/expr2.py
3.64365308249539388e-01
% lpython examples/expr2.py
3.07370851425161074e-01
% lpython examples/expr2.py
3.32739978717984608e-01
% lpython examples/expr2.py
4.64277766861150853e-01
% lpython examples/expr2.py
5.95815555004317154e-01
% lpython examples/expr2.py
4.84954742474926037e-01
% lpython examples/expr2.py
3.07370851425161074e-01
% lpython examples/expr2.py
1.26658859256030459e-01
% lpython examples/expr2.py
6.79743189681201843e-01
% lpython examples/expr2.py
4.67405867980516476e-01
% lpython examples/expr2.py
7.43338167082210122e-01
% lpython examples/expr2.py
8.85824309143155908e-01
% lpython examples/expr2.py
4.20140032852133749e-01
% lpython examples/expr2.py
3.44032650973663034e-01
% lpython examples/expr2.py
9.11193436435979498e-01
% lpython examples/expr2.py
1.77397113841677612e-01
% lpython examples/expr2.py
2.67925269095192320e-01
% lpython examples/expr2.py
6.11800378939043932e-01
% lpython examples/expr2.py
9.28742310930389170e-01
% lpython examples/expr2.py
5.38821098179938729e-01
% lpython examples/expr2.py
6.38733556791550305e-01
% lpython examples/expr2.py
9.69751943820040596e-01
% lpython examples/expr2.py
1.89261478460049960e-02
% lpython examples/expr2.py
7.01984215854659754e-01

@Shaikh-Ubaid
Copy link
Collaborator Author

The CI macos test runs indefinitely. This is also experienced in the main branch CI run.

@certik
Copy link
Contributor

certik commented Jan 22, 2024

The CI macos test runs indefinitely. This is also experienced in the main branch CI run.

This is due to #2455.

@Shaikh-Ubaid Shaikh-Ubaid marked this pull request as ready for review January 23, 2024 17:12
@Shaikh-Ubaid Shaikh-Ubaid marked this pull request as draft January 23, 2024 17:14
This ensures srand() gets different (far-away) values for two
subsequent executions of the compiler.
assert t1 != t2
assert t1 == t3
assert t1 != t4
assert t1 != t5
assert t4 == t5
assert t6 != t7
# assert t6 != t7
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@certik I commented this out as we discussed in the meet.

@Shaikh-Ubaid Shaikh-Ubaid marked this pull request as ready for review January 23, 2024 18:26
Copy link
Contributor

@certik certik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That should be good.

@Shaikh-Ubaid
Copy link
Collaborator Author

The macos CI failed thrice in this PR. It seems like it is more of an actual issue than a flaky one. Since the macos CI also fails in the main branch, I think it is fine to merge this PR. @certik I could not find any option to merge a PR when the CI does not pass completely. Do you know how to merge this PR?

@certik certik merged commit 693afee into lcompilers:main Jan 26, 2024
12 of 13 checks passed
@certik
Copy link
Contributor

certik commented Jan 26, 2024

Yes, the CI issue is real, something goes wrong.

@Shaikh-Ubaid Shaikh-Ubaid deleted the fix_random2 branch January 26, 2024 21:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

The random numbers do not seem to work
2 participants