Ask Your Question

# Problem getting indices to sync up

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.

edit retag close merge delete

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

( 2013-05-30 07:46:19 -0500 )edit

## 1 answer

Sort by ยป oldest newest most voted

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

more

## Comments

Thanks very much @John for your help

( 2013-05-30 10:18:01 -0500 )edit

## Your Answer

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

Add Answer

## Stats

Asked: 2013-05-30 07:37:25 -0500

Seen: 100 times

Last updated: May 30 '13