Use the real dtype in case of mixed dtype input and work around dtype change depending of numpy version.