Hi, On Mon, Apr 19, 2010 at 02:09:04PM -0600, Aaron S. Meurer wrote: > Lists are unhashable in every Python. If you want to use them as keys in a > dictionary, you have to use tuples instead. You can probably fix it by doing > > dict([ (tuple(map(int, monom)), coeff) for monom, coeff in M[0,0] ]) > > (though I haven't tried it). >
exactly, I forgot that map() doesn't preserve container type. > Aaron Meurer > On Apr 19, 2010, at 1:43 PM, Ben Goodrich wrote: > > > Hi Mateusz, > > > > I think I understand but ... > > > > On Apr 19, 12:13 pm, Mateusz Paprocki <matt...@gmail.com> wrote: > >> They look identical, but they're not. As you use F.as_dict(), then in > >> both cases c_i are of type Integer. However, keys of _50 and _51 are > >> different. In _50 M_i are tuples of Integer instances and in _51 they > >> are tuples of ints. When you created a Matrix of FF then FF got sympified > >> and all ints were converted to Integers. Poly, however, expects M_i to > >> have int exponents. To solve this problem you can replace dict(M[0,0]) > >> with: > >> > >> dict([ (map(int, monom), coeff) for monom, coeff in M[0,0] ]) > > > > this results in an error > > > > In [12]: dict([ (map(int, monom), coeff) for monom, coeff in M[0,0] ]) > > --------------------------------------------------------------------------- > > TypeError Traceback (most recent call > > last) > > > > /tmp/mattpap-sympy-polys-cd30a32/<ipython console> in <module>() > > > > TypeError: list objects are unhashable > > > > Maybe you meant something slightly different? Or is it another Python > > 2.5 vs 2.6 thing? > > > > Thanks, > > Ben > > > > -- > > You received this message because you are subscribed to the Google Groups > > "sympy" group. > > To post to this group, send email to sy...@googlegroups.com. > > To unsubscribe from this group, send email to > > sympy+unsubscr...@googlegroups.com. > > For more options, visit this group at > > http://groups.google.com/group/sympy?hl=en. > > > > -- > You received this message because you are subscribed to the Google Groups > "sympy" group. > To post to this group, send email to sy...@googlegroups.com. > To unsubscribe from this group, send email to > sympy+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/sympy?hl=en. > -- Mateusz
signature.asc
Description: This is a digitally signed message part