On 3/19/07, Mike Hansen <[EMAIL PROTECTED]> wrote: > > <type 'exceptions.TypeError'>: unhashable type: > > 'sage.rings.complex_number.ComplexNumber' > > You should be able to just add the following to the ComplexNumber class: > > def __hash__(self): > return str(self).__hash__() > > That should work so long as the complex number is completely > determined by its __str__. I'm not sure if ComplexNumbers are mutable > or immutable, but if they are mutable, you need to make sure not to > change them while they are dictionary keys; otherwise, bad things will > happen.
Complex numbers are immutable. All numeric types in SAGE are immutable, including polynomials. The only elements that are not immutable are matrices (which can be set immutable), and vectors (which will soon have an immutability flag too). I've attached a patch for some numerical hashing to this email. > I'm not sure about the sort under sagex which reminds me that I should > get a better understanding of pyrex. Sorting under sagex is exactly the same as under Python, unless you want to something new at the C level. E.g., you can use L.sort(cmp=...) if L is a list. --~--~---------~--~----~------------~-------~--~----~ To post to this group, send email to sage-devel@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sage-devel URLs: http://sage.scipy.org/sage/ and http://modular.math.washington.edu/sage/ -~----------~----~----~----~------~----~------~--~---
3490.patch
Description: Binary data