[Numpy-discussion] OpenOpt Suite release 0.45

Alan G Isaac alan.isaac at gmail.com
Wed Apr 10 08:11:46 EDT 2013

On 4/10/2013 3:31 AM, Robert Kern wrote:
> You cannot use objects that do not have a valid __eq__() (as in,
> returns boolean True if and only if they are to be considered
> equivalent for the purpose of dictionary lookup, otherwise returns
> False) as dictionary keys. Your oofun object still violates this
> principle. As dictionary keys, you want them to use their `id`
> attributes to distinguish them, but their __eq__() method still just
> returns another oofun with the default object.__nonzero__()
> implementation. This means that bool(some_oofun == other_oofun) is
> always True regardless of the `id` attributes. You have been
> unfortunate enough to not run into cases where this causes a problem
> yet, but the bug is still there, lurking, waiting for a chance hash
> collision to silently give you wrong results. That is the worst kind
> of bug.

Hi Dmitrey,

Robert and Sebastien have taken their time to carefully explain
to your why your design is flawed.  Your response has been only
that you rely on this design flaw and it has not bitten you yet.
I trust you can see that this is truly not a response.

The right response is to explore how you can refactor to
eliminate this lurking bug, or to prove that it can *never*
bite due to another design feature.  You have done neither,
and the second looks impossible.  So you have work to do.

You say that you *must* use oofuns as dict keys.  This is probably
false, but you clearly want to retain this aspect of your design.
But this choice has an implication for the design of oofuns,
as carefully explained in this thread.  So you will have to
change the design, even though that may prove painful.
No smaller step is adequate to the quality of software you
aspire to.

One last thing.  When someone like Robert or Sebastien take their
time to explain a problem to you, the right response is "thank you",
even if their news is unwelcome.  Don't shoot the messenger.


More information about the NumPy-Discussion mailing list