Dear Andrew,

On Sun, Aug 19, 2012 at 04:52:45PM -0700, Andrew Mathas wrote:
>    Recently when playing around with standard tableaux, which are enumerated
>    sets, I rewrote their getitem methods because I thought that they should
>    support slices. At the time I thought that this should go into the
>    enumerated set code but I wasn't sure where to put it. Modulo the
>    documentation, __getitem__ for the standard tableaux classes now looks
>    like this:"
>     def __getitem__(self, r):
...
>    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]

Yes, this is a practical feature for interactive use. On the other
hand, it should not be used in code manipulating a generic enumerated
set. Indeed, for many of those we want to reserve indexed access for
something more mathematically meaningful; think for example a family,
like the basis of a vector space indexed by the partitions of 3:

    sage: F = CombinatorialFreeModule(QQ, Partitions(3)).basis()
    sage: F
    Lazy family  (...)_{i in Partitions of the integer 3}
    sage: F[Partition([2,1])]
    B[[2, 1]]

The default __getitem__ for parents is implemented in Parent. It
really should be in (Finite)EnumeratedSets (see #12955). And
supporting slices could be added there indeed. With an appropriate
warning mentioning that this should be reserved for interactive use or
non generic code.

As far as I know, no one is currently working on #12955.

>    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.

They do! With Sage 5.2 with no patches applied:

    sage: f = InfiniteEnumeratedSets().example(); f
    An example of an infinite enumerated set: the non negative integers
    sage: f.is_finite()
    False
    sage: f.is_finite??
    Source File:        
/opt/sage-5.2/devel/sage/sage/categories/infinite_enumerated_sets.py
        def is_finite(self):
            return False

    sage: f = FiniteEnumeratedSets().example()
    sage: f.is_finite()
    True
    sage: f.is_finite??
    Source File:        
/opt/sage-5.2/devel/sage/sage/categories/finite_enumerated_sets.py
        def is_finite(self):
            return True

Cheers,
                                Nicolas
--
Nicolas M. ThiƩry "Isil" <nthi...@users.sf.net>
http://Nicolas.Thiery.name/

-- 
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