BUG: Fixes #5376: np.ravel to return same array type

See commit message for details.
Probably need a version reference for this change.