Added assert to ensure that the maximum rank is equal to the number of merged samples