On 14/04/15 11:45, Jori Mantysalo wrote:
Just wondering, so feel free to ignore.
I noticed that MatrixSpace(GF(3), 4, 5).cardinality() raises an
exception. However, there is __len__:
sage: MatrixSpace(GF(3), 4, 5).__len__()
3486784401
sage: len(MatrixSpace(GF(3), 4, 5))
3486784401
but
sage: MatrixSpace(GF(2003), 4, 5).__len__()
1080485606479352381688319506340455348506693332851960692625585464401L
sage: len(MatrixSpace(GF(2003), 4, 5))
. . . OverflowError: long int too large to convert to int
I don't get this. Is `len` somehow internally redefined in Sage? Where?
What is the meaning of len and __len__? Should there be .cardinality()
in all Sage objects where it has some meaning?
This is pure Python, `len(X)` just calls `X.__len__()` and do a cast
sage: class A:
....: def __len__(self): return "haha"
sage: a = A()
sage: len(a)
Traceback (most recent call last):
...
TypeError: __len__() should return an int
It would indeed be better to also support a cardinality method for
`MatrixSpace` (be careful to return a Sage integer there) and to support
the following
sage: MatrixSpace(GF(3),4,5) in FiniteSets()
True
(this is currently returning False)
Vincent
--
You received this message because you are subscribed to the Google Groups
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sage-devel.
For more options, visit https://groups.google.com/d/optout.