Ask Your Question
0

var list with only one variable error

asked 2019-08-14 09:00:37 +0100

ortollj gravatar image

updated 2023-01-09 23:59:51 +0100

tmonteil 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 12:44:46 +0100 )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 12:59:25 +0100 )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 14:06:15 +0100 )edit

1 Answer

Sort by ยป oldest newest most voted
2

answered 2019-08-14 14:14:14 +0100

Iguananaut gravatar image

updated 2019-08-14 14:15:02 +0100

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 09:00:37 +0100

Seen: 356 times

Last updated: Aug 14 '19