Hi Andrew,
> I don't know whether this is generally thought to be a good idea, but I
> like being able to write things like:
>
> sage: StandardTableaux(40)[0:10]
I like it also! And hacking the __getitem__ for any enumerated set is
not that hard. The standard way to access the i-th tableau is by
StandardTableaux(40).unrank(i). Then you could implement a __getitem__
method based on unrank inside
sage.categories.enumerated_sets.EnumeratedSets.ParentMethods.
> Btw, I also think that the InfiniteEnumeratedSet and FiniteEnumerated set
> categories should define an is_finite() method which returns False and
> True, respectively. As far as I could see, there is no easy way to ask them
> whether they are finite or infinite.
>From the actual category framework there are three categories
* EnueratedSets
* FiniteEnumeratedSets
* InfiniteEnumeratedSets
For the two last, there is a method .cardinality() which should tell
you whether the set is finite or not. But it definitely not a good
solution as it may be time consuming for a finite set to tell the
cardinality. The best option is
if my_set in FiniteSets():
# some stuff for finite sets
...
elif my_set in InfiniteSets():
# some stuff for infinite sets
...
elif my_set in Sets():
# some stuff for finite or infinite sets
...
else:
raise ValueError("this is not a set!")
I think that the above code is enough clear to get rid of a is_finite method.
Best,
Vincent
--
You received this message because you are subscribed to the Google Groups
"sage-combinat-devel" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/sage-combinat-devel?hl=en.