Hi Anne,

On Tue, Jun 07, 2011 at 09:43:52PM -0700, Anne Schilling wrote:
> Trying to get to coefficients of certain terms in symmetric functions, I am 
> running
> into trouble:
> 
> sage: ks = kSchurFunctions(QQ,3,t=1)
> sage: f=ks([3,2])+ks([2])
> sage: f.monomial_coefficients()
> {[3, 2]: 1, [2]: 1}
> sage: f.monomial_coefficients().keys()[1].parent()
> Partitions of the integer 2
> sage: P=f.monomial_coefficients().keys()[1].parent()
> sage: f.coefficient(P([2]))
> ---------------------------------------------------------------------------
> AssertionError                            Traceback (most recent call last)
> AssertionError: [2] should be an element of Partitions of the integer An 
> example of an infinite enumerated set: the non negative integers satisfying 
> constraints max_part=3
> 
> 
> Why are the parents of the keys different from the actual objects?

Because the basis of kschur functions is indexed by:

    sage: ks.basis().keys()
    Partitions of the integer An example of an infinite enumerated set: the non 
negative integers satisfying constraints max_part=3

Ouch; the name of this parent is meaningless; but looking at the
source, you can see that it is:

    sage: Partitions(NonNegativeIntegers(), max_part = 3)
    Partitions of the integer An example of an infinite enumerated set: the non 
negative integers satisfying constraints max_part=3

This set has been implemented as a facade parent, so that its elements
are plain Partitions. However, this was implemented before appropriate
framework was available for facade parents. In particular this parent
does not recognizes its own objects (which is the problem you are
encountering), and the TestSuite fails horribly. This should be fixed
when partitions will be refactored to use categories, factories, and
the like.

In the mean time, you can access coefficients using the [] notation
which is faster and less picky:

    sage: f[Partition([3,2])]
    1
    sage: f[Partition([3,2,1])]
    0

By the way, a shorter idiom for:

    sage: f.monomial_coefficients().keys()[1]

is:

    sage: f.support()[1]

In general, I very seldom use monomial_coefficients.

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