Ask Your Question

weird behavior of set and uniq

asked 2017-03-31 12:15:11 -0500

roberto gravatar image

updated 2017-08-01 05:22:13 -0500

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

edit retag flag offensive close merge delete

1 answer

Sort by » oldest newest most voted

answered 2017-04-01 04:04:00 -0500

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

For more details about the difference between symbolic expressions and coordinate functions see

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


Asked: 2017-03-31 12:15:11 -0500

Seen: 45 times

Last updated: Apr 01 '17