Fix bug where ``nanops._has_infs`` doesn't work with many dtypes (issue #7357)

Fixes issue #7357, where where ``nanops._has_infs`` doesn't work with many dtypes
The fix for the issue in #7440 is here