Opened 7 years ago
Last modified 5 years ago
#12580 new enhancement
set_random_seed does not seed Python's random number generator
Reported by: | mariah | Owned by: | jason |
---|---|---|---|
Priority: | major | Milestone: | sage-6.4 |
Component: | misc | Keywords: | |
Cc: | Merged in: | ||
Authors: | Reviewers: | ||
Report Upstream: | N/A | Work issues: | |
Branch: | Commit: | ||
Dependencies: | Stopgaps: |
Description
William Stein reported on sage.devel:http://groups.google.com/group/sage-devel/browse_thread/thread/5fa8e919dd83b4b7:
sage: import random sage: set_random_seed(0); random.randint(0,20) 3 sage: set_random_seed(0); random.randint(0,20) 8
William said "Basically, I expected that Sage's "set_random_seed" would actually set *Python*'s own random seed, given that it sets gp, gap, maxima, etc."
Change History (6)
comment:1 Changed 7 years ago by
comment:2 Changed 6 years ago by
- Milestone changed from sage-5.11 to sage-5.12
comment:3 Changed 5 years ago by
- Milestone changed from sage-6.1 to sage-6.2
comment:4 Changed 5 years ago by
- Milestone changed from sage-6.2 to sage-6.3
comment:5 Changed 5 years ago by
- Milestone changed from sage-6.3 to sage-6.4
comment:6 Changed 5 years ago by
- Priority changed from critical to major
- Type changed from defect to enhancement
Certainly not critical. Not a defect either.
Note: See
TracTickets for help on using
tickets.
From the documentation of
sage.misc.randstate
:Indeed,
So, Witty's design was to wrap python's random functionality to get it to respect set_random_seed rather than reach into python and change the seed there. Perhaps he had thread-safety in mind or something like that?
With that design, the behaviour noted in this ticket is not a bug but a feature that arises from circumventing the advertised API.
This ticket can still be considered as a request: can we reconsider the design decisions made in
randomstate
, of course.