Hi Vincent,

For partitions, compositions, tableau it might make sense for a slice to 
return an object of the same type. Although I would be against making this 
feature completely consistent because, for example, I definitely want the 
following behaviour to remain:

sage: Partition([4,4,3,2])[2]
3

It wouldn't be hard, however, to make "honest" slices to return the object 
provided that we are happy with

sage: Partition([4,4,3,2])[2] != Partition([4,4,3,2])[2:3]
True

Treating shifts consistently appears tobe problematic. For example, what 
should the following return?

sage: Partition([4,4,3,2])[::-1] == Composition([2,3,4,4])

You suggested that this should return False but I find the argument for 
True equally compelling...
 
Regarding the choice of the "correct" parent for these objects I think that 
it should be the smallest meaningful parent which makes meaningful sense in 
terms of the code. For example, the same issue arises when restricting 
tableau. If a tableau is (semi)standard then I wanted to ensure that the 
restriction was still (semi)standard. Giving the restriction the "best" 
parent in terms of shape or weight is not worth doing, however, as most of 
the time this is something that you would have to check if it was important 
mathematically  and -- more significantly -- it makes no difference in 
terms of the code as none of the implemented methods depend on this.

Best,
Andrew


On Friday, 7 September 2012 21:12:59 UTC+10, Vincent Delecroix wrote:
>
> Hello, 
>
> I do have a question linked to categorification of sage.combinat.words 
> (trac #12224), Subwords (trac #10534) and graded sets (trac #10193). 
>
> For object like integer partition, compositions or words, it make 
> sense to take slices. In the current implementation we do have quite 
> different behavior for slices and parents 
> {{{ 
> sage: p = Partition([3,2,2,1]) 
> sage: type(p[1:5]) 
> <type 'list'> 
> sage: p.parent() 
> Partitions of the integer 8 
>
> sage: c = Composition([1,3,2,1,3]) 
> sage: type(c[1:5]) 
> <type 'list'> 
> sage: c.parent() 
> Compositions of non-negative integers 
>
> sage: w = Word([1,3,3,1,2,1]) 
> sage: type(w[1:5]) 
> <class 'sage.combinat.words.word.FiniteWord_list'> 
> sage: w.parent() 
> Free monoid over {1, 2, 3}       # this is the new implementation!! 
> }}} 
>
> Note that for partitions, slice with negative step is not defined. I 
> would like that p[1:5] returns a partition and p[5:1:-1] returns an 
> error (or a list). 
>
> For such objects, it is possible to consider factors, subwords, 
> shuffle product... but it is quite hard to have a common 
> implementation for all of them (shuffle product needs to work for 
> compositions and words). It would be nice to have a sort of protocol 
> for sliceable elements in Sage in order to allow functorial 
> construction as Subwords or ShuffleProduct. 
>
>  * Do we need that a slice like p[1:5] returns an object of the "same 
> family" ? 
>  * Is it interesting to make "Subwords(Partition([3,2,1,1]))" work ? 
>  * What should be the default parent of Partition([3,2,1]), 
> Composition([3,2,3,1]) or Word([1,2,1,2,3]) ? We have many choices. As 
> an example, for Partition([3,2,1]) have four natural parents 
>     * partitions 
>     * partitions of 6 
>     * partitions of length 3 
>     * partitions of 6 of length 3 
>  * Does slice make sense for other Sage objects ? 
>
> Best, 
> Vincent 
>

-- 
You received this message because you are subscribed to the Google Groups 
"sage-combinat-devel" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/sage-combinat-devel/-/fLp-k0K1LkEJ.
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