Ask Your Question
0

Bug in initializing random

asked 2012-01-23 12:09:55 +0200

kartikv gravatar image

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?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2012-01-23 13:29:26 +0200

Jason Grout gravatar image

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.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2012-01-23 12:09:55 +0200

Seen: 238 times

Last updated: Jan 23 '12