If I try to find the sum of a vector of floats that way, it works as
expected:
sage: vector([1,float(2),3]).sum()
-> 6.0

However, applying the same logic on a vector made of integers:
sage: vector([1,2,3]).sum()
-> Traceback (click to the left of this block for traceback)
    ...
    AttributeError:
'sage.modules.vector_integer_dense.Vector_integer_dense'
    object has no attribute 'sum'

Workaround (thanks to Dr. Drake) is to call the sum function directly
like this:
sage: sum(vector([1,2,3]))
-> 6

Browsing through the code, one can find the .sum() method being
defined for floats at the end of the file vector_double_dense.pyx,
while this method is absent in the vector_integer_dense.pyx.

Did I luckily stumbled on a rarity, or should this self.sum() method
be part of every types' definition? (where applicable). in any case,
uniformity would help (method present in every type definition /
completely removed) to prevent confusion.

-- 
To post to this group, send an email to sage-devel@googlegroups.com
To unsubscribe from this group, send an email to 
sage-devel+unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URL: http://www.sagemath.org

Reply via email to