Bug in initializing random

i like this post (click again to cancel)
0
i dont like this post (click again to cancel)

Or maybe a feature? In normal python + numpy

import numpy.random as random random.RandomState(22)

works as expected, whereas in sage, the input has to be an array (e.g. [22]). Anyone know why?

asked Jan 23 '12

kartikv gravatar image kartikv
31 4
i like this answer (click again to cancel)
0
i dont like this answer (click again to cancel)

This is because numpy does not recognize Sage integers as scalars. This is arguably a bug in numpy (since it is checking for scalars by looking at the type, rather than trying to coerce to an integer using the standard python functions to do so). A workaround is to use int(22) or 22r (i.e., a 'raw' 22) instead.

link

posted Jan 23 '12

Jason Grout gravatar image Jason Grout
3185 7 27 71

Your answer

Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!
[hide preview]

Question tools

Tags:

Stats:

Asked: Jan 23 '12

Seen: 31 times

Last updated: Jan 23 '12

powered by ASKBOT version 0.7.22
Copyright Sage, 2010. Some rights reserved under creative commons license.