Dear Jean-Yves,

> OK, but there is some inconsistent behavior, anyway:
> 
> 
> sage: P=Partitions(4)
> sage: len(P)
> 5
> sage: C=Compositions(4)
> sage: len(C)
> ---------------------------------------------------------------------------
> AttributeError                            Traceback (most recent call last)
> 
> /home/jyt/monge/TEX/QSCHUR/<ipython console> in <module>()
> 
> /home/jyt/src/sage-5.4.1/local/lib/python2.7/site-packages/sage/combinat/combinat.py
>  
> in __len__(self)
>     972             AttributeError: __len__ has been removed; use 
> .cardinality() instead
>     973         """
> --> 974         raise AttributeError, "__len__ has been removed; use 
> .cardinality() instead"
>     975 
>     976     def count(self):
> 
> AttributeError: __len__ has been removed; use .cardinality() instead
> sage: R=reversed(P)
> sage: list(R)
> [[1, 1, 1, 1], [2, 1, 1], [2, 2], [3, 1], [4]]

Yes ! As you probably already guessed, everything is not yet in a clean
state... The first call should raise the same error than the second one. We
can't answer consistently to len because Python specified it as being a
machine integer. This is much too small for cardinality of combinatorial set
and prevent for returning infinity. So as the error message tell you, please
write

sage: P=Partitions(4)
sage: P.cardinality()
5

sage: P=Partitions(4000)
sage: P.cardinality()
1024150064776551375119256307915896842122498030313150910234889093895

sage: P=Partitions()
sage: P.cardinality()
+Infinity

And indeed, I think that

sage: len(Compositions(4000))
[...]
AttributeError: __len__ has been removed; use .cardinality() instead

Is a much clean behavior than:

sage: len(Partitions(4000))
[...]
RuntimeError: maximum recursion depth exceeded in cmp

A++

Florent

-- 
You received this message because you are subscribed to the Google Groups 
"sage-combinat-devel" group.
To post to this group, send email to sage-combinat-devel@googlegroups.com.
To unsubscribe from this group, send email to 
sage-combinat-devel+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sage-combinat-devel?hl=en.

Reply via email to