This should be changed to throw an exception in such a case. It would certainly be an error if there were ranks other than 0, 1, 2 in the data.