First time here? Check out the FAQ!

Ask Your Question
0

Calling the length of a list of inequality strings result in an error

asked 3 years ago

Cyrille gravatar image

I wonder if this is a bug

sign=['>=', '<=', '=']
m1=[1 if (v=="<=" or v==">=") else 2 for v in sign]
m1

The len(m1) is defined but

y=var('y_',n=range(len(m1)))

return the error '>' not supported between instances of 'range' and 'int'

Preview: (hide)

Comments

Note that len(m1) will be the same as len(sign). Do you want the length of m1 or the number of distinct elements or the actual distinct elements? For the last of these, you could use var(['y_{}'.format(i) for i in set(m1)]).

John Palmieri gravatar imageJohn Palmieri ( 3 years ago )

1 Answer

Sort by » oldest newest most voted
1

answered 3 years ago

tmonteil gravatar image

The n option for SR.var is supposed to be an integer, not an iterator. Do you mean the following ?

sage: y = var('y_', n=len(m1))
sage: y
(y_0, y_1, y_2)
Preview: (hide)
link

Comments

Yes I am stupid

Cyrille gravatar imageCyrille ( 3 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

1 follower

Stats

Asked: 3 years ago

Seen: 211 times

Last updated: Mar 29 '22