First time here? Check out the FAQ!

Ask Your Question
0

Problem getting indices to sync up

asked 11 years ago

JoshIzzard gravatar image

I'm not sure what is wrong with the following code:

# given a prime p, return all A_n representations of dimension = p^2
def rankrep(p):
    bound = p**2
    A = lambda i: WeylCharacterRing("A{0}".format(i), style = "coroots")
    deg = []
    for i in xrange(bound):
        deg.append([])
        fw = A(i+1).fundamental_weights()
        temp = A(i+1)
        for j in range(len(fw)):
            deg[i].append(temp(fw[j]).degree())
    return deg

But when I run it, it is unable to return anything, and tells me Keyval Error 0. Should I not be using append here?

I eventually hope to insert some if trees testing whether a given temp(fw[j].degree() == p**2, but I'm not sure how to pull those indices either. Any help would be greatly appreciated. Regards.

Preview: (hide)

Comments

I've added this line of code ` [(i,j) for (i,deg_i) in enumerate(deg) for (j,deg_ij) in enumerate(deg_i) if deg_ij == p**2]` to pull the indices

JoshIzzard gravatar imageJoshIzzard ( 11 years ago )

1 Answer

Sort by » oldest newest most voted
2

answered 11 years ago

Try replacing

    for j in range(len(fw)):

with

    for j in fw.keys():

(In your code, fw is not a list, but a finite family, so its entries are not indexed by 0, 1, 2, ..., necessarily.)

Preview: (hide)
link

Comments

Thanks very much @John for your help

JoshIzzard gravatar imageJoshIzzard ( 11 years ago )

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 11 years ago

Seen: 308 times

Last updated: May 30 '13