Re: Floats as keys in dict

2007-08-02 Thread Brian Elmegaard
greg <[EMAIL PROTECTED]> writes: > Be careful with this. If you have two values that are > very close together, but on different sides of a rounding > boundary, they will end up as distinct keys even though > they "should" be regarded as equal. I don't think this is a big problem. It will only gi

Re: Floats as keys in dict

2007-08-01 Thread greg
Brian Elmegaard wrote: > However, the dict keys are then floats and I have to round the values > of new possible nodes in each step. Be careful with this. If you have two values that are very close together, but on different sides of a rounding boundary, they will end up as distinct keys even thou

Re: Floats as keys in dict

2007-08-01 Thread Brian Elmegaard
Steve Holden <[EMAIL PROTECTED]> writes: > Alex Martelli wrote: [snip] Thanks a lot for your intersting answers. I will start out taking a look at bisect. -- Brian (remove the sport for mail) http://www.et.web.mek.dtu.dk/Staff/be/be.html http://www.rugbyklubben-speed.dk -- http://mail.python

Re: Floats as keys in dict

2007-08-01 Thread Steve Holden
Alex Martelli wrote: > Brian Elmegaard <[EMAIL PROTECTED]> wrote: > >> I am making a script to optimiza by dynamic programming. I do not know >> the vertices and nodes before the calculation, so I have decided to >> store the nodes I have in play as keys in a dict. >> >> However, the dict keys are

Re: Floats as keys in dict

2007-08-01 Thread Alex Martelli
Brian Elmegaard <[EMAIL PROTECTED]> wrote: > I am making a script to optimiza by dynamic programming. I do not know > the vertices and nodes before the calculation, so I have decided to > store the nodes I have in play as keys in a dict. > > However, the dict keys are then floats and I have to ro

Floats as keys in dict

2007-08-01 Thread Brian Elmegaard
Hi I am making a script to optimiza by dynamic programming. I do not know the vertices and nodes before the calculation, so I have decided to store the nodes I have in play as keys in a dict. However, the dict keys are then floats and I have to round the values of new possible nodes in each step.