Ask Your Question
0

weird behavior of set and uniq

asked 2017-03-31 19:15:11 +0100

roberto gravatar image

updated 2017-08-01 12:22:13 +0100

FrédéricC gravatar image

Hi all, I have a list of coefficients (which are variables) and I want to remove duplicates. In my original file (from May 2015) I could use set and or unique now both of them give me the same error

TypeError: <class 'sage.manifolds.coord_func_symb.CoordFunctionSymbRing_with_category.element_class'> is not hashable

Whenever I try to use the same commands with another list I don't have any error. I'm still scratching my head. here is the notebook. I don't have enough karma to publish a link

cloud.sagemath.com/projects/263f082f-dc10-4817-a88d-d87700640552/files/Ask+sage.html

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
0

answered 2017-04-01 11:04:00 +0100

eric_g gravatar image

You should create the list res_coef from symbolic expressions, not directly from the coordinate functions representing the coefficients. To get the symbolic expression of the coordinate function res[ind], use the method expr(). Hence if you replace res[ind]**2 in your input In[5] by res[ind].expr()**2, everything works, as you can see on https://cloud.sagemath.com/projects/5...

For more details about the difference between symbolic expressions and coordinate functions see http://doc.sagemath.org/html/en/refer...

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: 2017-03-31 19:15:11 +0100

Seen: 320 times

Last updated: Apr 01 '17