# Sort data into clusters
94 assignments = np.array(view.Zr().values())
95 row_indexes = np.argsort(assignments, kind='mergesort')
It is worth checking whether view.Zr().keys() is sorted ascending, since its an OrderedDict which only maintains insertion order not key order. If the keys are not sorted ascending, then numpy argsort is returning indices which do not match their original assignments -- the third item in view.Zr()[3] is not guaranteed to correspond to view.Zr().values()[3], for example.
One fix is something along the lines of row_indexes = sorted(view.Zr(), key=view.Zr).
https://github.com/probcomp/cgpm/blob/20161006-leocasarsa-fixing-logpdfmultirow-crosscat/src/utils/render_utils.py#L94-L95
It is worth checking whether
view.Zr().keys()
is sorted ascending, since its anOrderedDict
which only maintains insertion order not key order. If the keys are not sorted ascending, then numpy argsort is returning indices which do not match their original assignments -- the third item inview.Zr()[3]
is not guaranteed to correspond toview.Zr().values()[3]
, for example.One fix is something along the lines of
row_indexes = sorted(view.Zr(), key=view.Zr)
.