(1) I don't understand the question. What does your question mean?
(2) Possibly you should also ask on the scipy support list, where
there are likely to be more scipy experts...
--
William Stein
Associate Professor of Mathematics
University of Washington
http://wstein.org
sage: RealNumber=float; Integer=int
or, explicitly define the number type when calling the scipy function.
Good luck,
Kevin Horton
Robert Bradshaw just posted a patch to #5081 that makes this work:
sage: from scipy import stats
sage: stats.binom.pmf(1,10,.56,0)
0.0034614823012532187
(no preparser magic or anything; it just works).
And there was much rejoicing in the land!
Jason
I just did
sage: hg_sage.apply('http://trac.sagemath.org/sage_trac/attachment/ticket/5081/5081-numpy-types.patch')
sage: quit
sage -br
...
sage: import numpy
sage: numpy.array([1,2,3]).dtype
dtype('int64')
w00t!
William
And the patch works, in that not only does numpy now work, but the
original problem that started this thread is resolved:
sage: scipy.stats.binom.pmf(1,10,.56,0)
0.0034614823012532187
However, this works
sage: scipy.stats.binom.pmf(1,10,.560000000000000000000,0)
0.0034614823012532187
but this doesn't:
sage: scipy.stats.binom.pmf(1,10,.56000000000000000000000000000000000000,0)
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
/Users/wstein/.sage/temp/teragon_2.local/93783/_Users_wstein__sage_init_sage_0.py
in <module>()
/Users/wstein/build/64bit/sage-4.1/local/lib/python2.6/site-packages/scipy/stats/distributions.py
in pmf(self, k, *args, **kwds)
3883 output = zeros(shape(cond),'d')
3884 place(output,(1-cond0)*(cond1==cond1),self.badvalue)
-> 3885 goodargs = argsreduce(cond, *((k,)+args))
3886 place(output,cond,self._pmf(*goodargs))
3887 if output.ndim == 0:
/Users/wstein/build/64bit/sage-4.1/local/lib/python2.6/site-packages/scipy/stats/distributions.py
in argsreduce(cond, *args)
246 # make sure newarr is not a scalar
247 newarr = atleast_1d(args[k])
--> 248 newargs[k] = extract(cond,newarr*expand_arr)
249 return newargs
250
TypeError: unsupported operand type(s) for *: 'numpy.ndarray' and 'numpy.bool_'
-- William
I can see that the above failing is by design (in the source code),
and seems sensible to me.
-- William
Wow! I tried it, and it solves all the problems I was having with
sage <-> numpy. I am very impressed. Kudos and thanks to Robert
Bradshaw. If I ever meet you, I'd be happy to buy you a beer, or
other beverage of your liking.
Will this change make it in sage 4.1, or will it slip to 4.1.1?
--
Kevin Horton
Ottawa, Canada
>
> On 9 Jul 2009, at 15:02, William Stein wrote:
>
>> On Thu, Jul 9, 2009 at 11:31 AM, Mikie<thephan...@hotmail.com>
>> wrote:
>>>
>>> Robert, how do I update my sage installation when you create a
>>> patch. Do I have to reinstall Sage?
>>> Thanx
>>
>> I just did
>>
>> sage: hg_sage.apply('http://trac.sagemath.org/sage_trac/attachment/
>> ticket/5081/5081-numpy-types.patch')
>>
>> sage: quit
>>
>> sage -br
>>
>> ...
>>
>> sage: import numpy
>> sage: numpy.array([1,2,3]).dtype
>> dtype('int64')
>>
>> w00t!
>
> Wow! I tried it, and it solves all the problems I was having with
> sage <-> numpy. I am very impressed.
Well, I figured it's about time someone did it :). I thought I was
going to have to patch the numpy c sources myself, but shortly after
diving into them I saw the much simpler solution.
> Kudos and thanks to Robert
> Bradshaw. If I ever meet you, I'd be happy to buy you a beer, or
> other beverage of your liking.
>
> Will this change make it in sage 4.1, or will it slip to 4.1.1?
Looks like 4.1 is already "out," so 4.1.1. Also, http://
trac.sagemath.org/sage_trac/ticket/6506 is up.
- Robert