Resolve "Failing tests in test_cluster_counts"
This fixes a bug in the implementation of ClusterCounts
that makes a set of test cases in TestClusteCounts
fails in MacOS with clang -O3
.
In an earlier discussion this issue was related to a possible 'non-stable' ordering and therefore it was suggested to check if the tests were too restrictive. However after a close inspection I realized that not only the ordering in the cluster counts was different but actually the result was wrong.
Tracing back for the error source I found out that ClusterCounts.get_cluster_counts
and ClusterCount.get_cluster_counts_info
returns output with different ordering, which will cause some errors as the python implementation relies on the fact that both outputs have the same order.
Why does it fail only in MacOS? Apparently (as is mentioned here) assigning an unordered_map
changes the internal order when using libc++ which is the default standard library on OSX. This does not happen with libstdc++ btw and might explain why the ordering is different when getClusterCount()
is called.
How to solve this? After some IRL conversation with @angqvist it was decided to modify the actual implementation of ClusterCounts._count_clusters
in the way that this only depends on the ClusterCounts.get_cluster_counts
function. In addition, get_cluster_counts_info
and set_cluster_counts_info
wont be exposed in Pybind11 while some changes are introduced in ClusterCounts.get_cluster_counts
in order to replace atomic numbers with atomic symbols.
Finally, _count_clusters
output is sorted in order to avoid difference in the string representation when using clang.
Closes #270 (closed)