On Mon, Jun 29, 2009 at 11:52 AM, Ahmed Fasih<wuzzyv...@gmail.com> wrote: > > Giovanni, try this instead: > > sage: numpy.random.multinomial(10, [.5,.5], size=20r) > > The only difference is the "r" suffix to the size argument. When you > type in numbers into sage, the pre-processor converts them to a base > ring, which you can see by doing: > > sage: preparse('numpy.random.multinomial(10, [.5,.5], size=20)') > "numpy.random.multinomial(Integer(10), [RealNumber('.5'),RealNumber('. > 5')], size=Integer(20))" > > Numpy support of these advanced sage types like Integer or RealNumber > is spotty, so appending the "r" suffix (r for raw) to numbers prevents > them from being preparsed. This is a sage thing, doesn't mean anything > in regular python. > > Another way to accomplish this is to pass in "size=int(20)". > > Sometimes it's a matter of guessing which number isn't playing nice. > There are a couple of things you can try: > 1) If you are doing only Numpy stuff and don't need any sage-specific > tools, you can use ipython without sage: "sage -ipython", or in the > notebook, by either choosing "python" in the syntax drop-down menu > instead of "sage", or by putting "%python" as the first line of cells. > 2) Turn off the preprocessor before chunks of Numpy code: "preparse > (False)". > 3) Find out where in the numpy or sage code this error is happening > and fix it. See Martin Albrecht's talk, '''How to get started > developing Sage" at http://wiki.sagemath.org/days16 >
Thanks for that very clear and detailed response. For the record, here's the link to the FAQ entry: http://wiki.sagemath.org/faq#Typeissuesusingscipy.2CcvxoptornumpyfromSage William --~--~---------~--~----~------------~-------~--~----~ 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 URLs: http://www.sagemath.org -~----------~----~----~----~------~----~------~--~---