Only convert array if needed

This is a fix for https://github.com/scipy/scipy/issues/4203