[SciPy-dev] numpy.cumproduct() documentation: bug?

Otto Tronarp otto@tronarp...
Wed Jul 4 12:36:24 CDT 2007


You want to specify the axis argument:
In [14]: a
Out[14]:
array([[1, 2],
        [3, 4],
        [5, 6]])

In [15]: cumsum(a, axis=0)
Out[15]:
array([[ 1,  2],
        [ 4,  6],
        [ 9, 12]])

In [16]: diff(a, axis=0)
Out[16]:
array([[2, 2],
        [2, 2]])


Regards,
Otto

On Jul 4, 2007, at 7:20 PM, dmitrey wrote:

> I started to modify the page, but I noticed that python cumsum,  
> cumprod,
> diff behavior differs from MATLAB one.
> for example,
>
> a
> array([[1, 2],
>        [3, 4],
>        [5, 6]])
>
> cumsum(a)
> array([ 1,  3,  6, 10, 15, 21])
>
> octave> cumsum([1 2; 3 4; 5 6])
> ans =
>
>    1   2
>    4   6
>    9  12
>
> diff(a)
> array([[1],
>        [1],
>        [1]])
>
> octave> diff([1 2; 3 4; 5 6])
> ans =
>
>   2  2
>   2  2
>
> Also, cumsum missed "out" description:
> help(cumsum):
> cumsum(x, axis=None, dtype=None, out=None)
>     Sum the array over the given axis.
>
> So let the description in the matlab webpage will be done by someone
> else, ok? Or just let it be scipped for now.
> Regards, D.
>
>
> Andrew Straw wrote:
>> dmitrey wrote:
>>
>>
>>> also, I think it would be nice to add cumsum, cumprod, diff to
>>> http://www.scipy.org/NumPy_for_Matlab_Users page
>>>
>>
>> Go for it!
>> _______________________________________________
>> Scipy-dev mailing list
>> Scipy-dev@scipy.org
>> http://projects.scipy.org/mailman/listinfo/scipy-dev
>>
>>
>>
>>
>
> _______________________________________________
> Scipy-dev mailing list
> Scipy-dev@scipy.org
> http://projects.scipy.org/mailman/listinfo/scipy-dev
>



More information about the Scipy-dev mailing list