MAINT: fix test failures and warning spam by being less clever when the principal branch does not exist, for the matrix functions that use inverse scaling and squaring