Ask Your Question
0

var list with only one variable error

asked 2019-08-14 02:00:37 -0600

ortollj gravatar image

updated 2019-08-14 06:10:23 -0600

Iguananaut gravatar image

Hi

SageMath 8.8 notebook OS=W10

why does it fail if L has only one variable ? :

L=['sd_1']
#L=['sd_1','sd_2']
varL=var(L)
show(varL)
edit retag flag offensive close merge delete

Comments

FWIW, when I run var(['x']) I get TypeError: unhashable type 'list'. Is this what you got? When reporting on a behavior please describe exactly the behavior you observed, and the behavior you expected instead.

Iguananaut gravatar imageIguananaut ( 2019-08-14 05:44:46 -0600 )edit

In any case, whether or not you got what I did, there seems to be a bug here in the treatment of var() on a single-item list or tuple.

Iguananaut gravatar imageIguananaut ( 2019-08-14 05:59:25 -0600 )edit

yes TypeError: unhashable type 'list' was the error I got

to avoid this error I did this little workaround:

if len(rL)==1 :
    rV=[var(rL[0])]
else :
    rV=var(rL)
cV=var(cL)
ortollj gravatar imageortollj ( 2019-08-14 07:06:15 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
2

answered 2019-08-14 07:14:14 -0600

Iguananaut gravatar image

updated 2019-08-14 07:15:02 -0600

It seems for now you'll have to do an ugly workaround like:

sage: var(L[0] if len(L) == 1 else L)

I have opened a ticket with a proposed fix to the bug: https://trac.sagemath.org/ticket/28353

edit flag offensive delete link more

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: 2019-08-14 02:00:37 -0600

Seen: 38 times

Last updated: Aug 14