Hello,
On Tue, Apr 28, 2009 at 12:29 PM, Alden <[email protected]> wrote:
>
> On two different computers running Ubuntu 9.04, I downloaded and built
> from source sage 3.4.1. I also downloaded scipy using the synaptic
> package manager. I am under the impression that python and scipy in
> sage lead completely separate lives from python and scipy outside
> sage. In normal python (i.e. running python from the command line),
> the following works fine:
This is correct.
> sage: import scipy.stats
> sage: scipy.stats.poisson.pmf(5,1)
When you type this, what get sent to Sage is the output of
sage: preparse('scipy.stats.poisson.pmf(5,1)')
'scipy.stats.poisson.pmf(Integer(5),Integer(1))'
Numpy/Scipy don't know how to deal with Sage's Integer class. You can
get around this in a number of ways:
1) Use the "r" notation for "raw" Python ints:
sage: preparse('scipy.stats.poisson.pmf(5r,1r)')
'scipy.stats.poisson.pmf(5,1)'
sage: scipy.stats.poisson.pmf(5r,1r)
array(0.00306566200976202)
2) Explicitly make ints:
sage: scipy.stats.poisson.pmf(int(5),int(1))
array(0.00306566200976202)
3) Turn off the preparser:
sage: preparser(False)
sage: scipy.stats.poisson.pmf(5,1)
array(0.00306566200976202)
sage: preparser(True)
4) Set Integer to be int (and RealNumber to be Float):
sage: Integer = int
sage: RealNumber = float
sage: scipy.stats.poisson.pmf(5,1)
array(0.00306566200976202)
--Mike
--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/sage-support
URLs: http://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---