In 2008 I wrote a group theory package. I've recently started using it again, and I found that one (at least) of my functions is broken in Mathematica 10. The problem is complicated to describe, but the essence of it occurs in this line:
l = Split[l, Union[#1] == Union[#2] &]
Here l is a list of sets. The intent of the line is to split l into sublists of identical sets. Each set is represented as a list of group elements. I say "sets" rather than "lists" because two sets are to be considered identical if they contain the same members in any order. This is the reason for comparing Unions of the sets.
This used to work, but now it doesn't. The problem is that sets that, as far as I can tell, are equal, do not compare equal by this test. fact, the comparison e1 == e2 for indistinguishable group elements e1 and e2 also sometimes fails to yield True. (It remains unevaluated; e1 === e2 evaluates to False.) The elements can be fairly complicated objects. For instance, in one case where I'm having this problem, ByteCount[e1] is 2448. But e1 and e2 are indistinguishable. For instance, ToString[FullForm[e1]] === ToString[FullForm[e2]] yields True.
I've shown one line where this failure to compare equal causes a problem. In this one case I could probably work around the problem by defining UpValues for e1 == e2 or e1 === e2. But, unfortunately, the problem raises its head in other contexts as well. For instance, I am trying to use GraphPlot to show a cycle graph of the elements. GraphPlot takes a list of edges of the form ei->ej. In order to recognize that edges ei->ej and ei->ek are both connected to ei, GraphPlot needs to know that the ei appearing in the first edge is the same as ei in the second. It doesn't, so I get a disconnected graph. Unlike Split, GraphPlot doesn't provide a hook to enable me to tell it how to test vertexes for equality, and it apparently doesn't use Equal or SameQ, either, as UpValues I define for those are not used.
(Sorry about the generic tag -- I couldn't find anything more specific. Suggestions welcome.)
EDIT: In response to Szabolcs request, here is the FullForm of such an object:
a = sdp[znz[1, 3],
aut[List[Rule[znz[1, 3], znz[1, 3]]],
List[Rule[znz[0, 3], znz[0, 3]], Rule[znz[1, 3], znz[1, 3]],
Rule[znz[2, 3], znz[2, 3]]],
Dispatch[List[Rule[znz[0, 3], znz[0, 3]],
Rule[znz[1, 3], znz[1, 3]], Rule[znz[2, 3], znz[2, 3]]]]],
Function[NonCommutativeMultiply[Slot[2], Slot[1]]]]
b = sdp[znz[1, 3],
aut[List[Rule[znz[1, 3], znz[1, 3]]],
List[Rule[znz[0, 3], znz[0, 3]], Rule[znz[1, 3], znz[1, 3]],
Rule[znz[2, 3], znz[2, 3]]],
Dispatch[List[Rule[znz[0, 3], znz[0, 3]],
Rule[znz[1, 3], znz[1, 3]], Rule[znz[2, 3], znz[2, 3]]]]],
Function[NonCommutativeMultiply[Slot[2], Slot[1]]]]
a === b
(* ==> False *)
Note that a and b are identical and ToString[a] === ToString[b] gives True.
==is not really an appropriate way of testing whether expressions are the same. It's meant to be used to represent mathematical equality between algebraic expressions. This is whya==bwon't evaluate toTrueorFalse. According to Mathematica,aandbstand for (complex) numbers here and whether they're equal depends on what isaandb. I think in your case===is the way to go. – Szabolcs Nov 18 '14 at 17:211.is inexact while1is exact. This is why I'm asking – Szabolcs Nov 18 '14 at 17:33Dispatchhas been changed in Mathematica 10, so it's the first suspect. – Szabolcs Nov 18 '14 at 17:58Dispatch. – Szabolcs Nov 18 '14 at 18:03