Hello all,
I have defined a structure type ProblemInstance with 3 fields (h,J, and a
dictionary called properties), and which to store a dictionary that
actually uses these structures as the key. I've defined == for these
objects as follows:
==(a::ProblemInstance,b::ProblemInstance)=(a.h==b.h)&&(a.J==b.J)&&(a.
properties==b.properties)
This function works as expected. And in a single session, if I create my
list of problem instances and then generate the dictionary from that, it
works fine. However, if I save my dictionary and a list of keys with
JLD.save and reload them in a new session:
instances=load("instances.jld","instances"); # the problem instances
my_dict =load("my_dict.jld","thedict"); # the dictionary, keys are the
instances
length([key==instances[1] for key in keys(my_dict)]) # returns 1, as each
problem instance occurs in my_dict only once
my_dict[instances[1]] # gives error: key not found
This is really odd behavior to me. Surely if == claims two things are
equal, then I should be able to index the dictionary by either one and
receive the result, no different than
a=5
b=5
a==b # returns true
[a=>"eleven"][b] # returns "eleven"
Am I missing some epistemological issue here or is this a bug of some kind?