[sage-support] Re: ValueError when using np.random.seed()
On 10/26/11 2:41 PM, Jose Guzman wrote: Hi everybody, When trying to set a seed in Sage: sage: import numpy as np sage: np.random.seed(10) I've got the following error: sage: np.random.seed(10) --- ValueError Traceback (most recent call last) $HOME/programming/Sage/tests/ipython console in module() $HOME/sage-4.7/local/lib/python2.6/site-packages/numpy/random/mtrand.so in mtrand.RandomState.seed (numpy/random/mtrand/mtrand.c:4842)() ValueError: object of too small depth for desired array However, if I do: sage: import numpy as np sage: np.random.seed(int(10)) everything works nicely. Not sure if we should set a seed in a different way in Sage (I am running Sage 4.7.1). I wonder if is there any easy way to solve this small bug (I would be happy to submit a patch). Most likely, the problem here is that numpy doesn't recognize Sage Integer objects as being convertable to python integers. I think this is a failing of numpy (it should check the __index__ method to see if it can convert the Integer to a python integer). This will solve the original problem: np.random.seed(10r) (10r tells the Sage preparser to not make 10 a Sage Integer object, but instead, make it a python raw integer). Jason -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org
Re: [sage-support] Re: ValueError when using np.random.seed()
thread hijack but not really Most likely, the problem here is that numpy doesn't recognize Sage Integer objects as being convertable to python integers. I think this is a failing of numpy (it should check the __index__ method to see if it can convert the Integer to a python integer). Speaking of numpy issues, does someone with more influence than I have (i.e. anyone with nonvanishing influence) want to reraise the http://trac.sagemath.org/sage_trac/ticket/10928 issue with the numpy guys? /thread hijack Doug -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org
[sage-support] Re: ValueError when using np.random.seed()
On 10/26/11 4:20 PM, D. S. McNeil wrote: thread hijack but not really Most likely, the problem here is that numpy doesn't recognize Sage Integer objects as being convertable to python integers. I think this is a failing of numpy (it should check the __index__ method to see if it can convert the Integer to a python integer). Speaking of numpy issues, does someone with more influence than I have (i.e. anyone with nonvanishing influence) want to reraise the http://trac.sagemath.org/sage_trac/ticket/10928 issue with the numpy guys? If you submit a numpy pull request, you will have more influence than the rest of us combined. You might say: email talks; code walks [1]. Jason [1] not-so-elegant reference to talking the talk vs. walking the walk -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org
[sage-support] Re: ValueError when using np.random.seed()
On 10/26/11 4:20 PM, D. S. McNeil wrote: thread hijack but not really Most likely, the problem here is that numpy doesn't recognize Sage Integer objects as being convertable to python integers. I think this is a failing of numpy (it should check the __index__ method to see if it can convert the Integer to a python integer). Speaking of numpy issues, does someone with more influence than I have (i.e. anyone with nonvanishing influence) want to reraise the http://trac.sagemath.org/sage_trac/ticket/10928 issue with the numpy guys? I should also say that fixing that trac ticket upstream may likely fix the subject of this thread as well. So it isn't really hijacking the thread. Jason -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org