#12580: set_random_seed does not seed Python's random number generator
------------------------+---------------------------------------------------
Reporter: mariah | Owner: jason
Type: defect | Status: new
Priority: critical | Milestone: sage-5.0
Component: misc | Keywords:
Work_issues: | Upstream: N/A
Reviewer: | Author:
Merged: | Dependencies:
------------------------+---------------------------------------------------
Comment(by nbruin):
From the documentation of `sage.misc.randstate`:
{{{
Note that wrappers of all the random number generation methods from
Python's :mod:`random` module are available at the Sage command
line, and these wrappers are properly affected by :meth:`set_random_seed`.
::
}}}
Indeed,
{{{
sage: set_random_seed(0); randint(0,20)
2
sage: set_random_seed(0); randint(0,20)
2
sage: set_random_seed(0); randint(0,20)
2
sage: type(randint(0,20))
<type 'int'>
}}}
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.
--
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/12580#comment:1>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica,
and MATLAB
--
You received this message because you are subscribed to the Google Groups
"sage-trac" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/sage-trac?hl=en.