I would find it more natural to only use the object dtype for non integer y. That would fix the doctest failure.