gerhard wrote:
> I just noticed that from sage
> x=numpy.mgrid[0.:1.:0.1]
> coerces the results to integers.
> 
> Is there a work-around?


Using the Numpy 1.2 spkg that will probably be in the next version of 
Sage, I get:

sage: import numpy
sage: x=numpy.mgrid[0.:1.:0.1]
sage: x

array([0.000000000000000, 0.100000000000000, 0.200000000000000,
        0.300000000000000, 0.400000000000000, 0.500000000000000,
        0.600000000000000, 0.700000000000000, 0.800000000000000,
        0.900000000000000], dtype=object)
sage: type(x[0])
<type 'sage.rings.real_mpfr.RealLiteral'>
sage: type(x[1])
<type 'sage.rings.real_mpfr.RealNumber'>

Is that what you want?


If you just want python floats, the problem is that Sage is making the 
"0." and the "1." into Sage Real Numbers:

sage: preparse('x=numpy.mgrid[0.:1.:0.1]')
"x=numpy.mgrid[RealNumber('0.'):RealNumber('1.'):RealNumber('0.1')]"


You can get python floats by doing converting the numbers you specify to 
floats:


sage: x=numpy.mgrid[float(0.):float(1.):float(0.1)]
sage: type(x[0])
<type 'numpy.float64'>
sage: type(x[1])
<type 'numpy.float64'>


There are other ways to get just python floats as well, but this is 
probably the easiest for a single line.

Thanks,

Jason


--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to sage-devel@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/sage-devel
URLs: http://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---

Reply via email to