Safely handle non-integer output shape specification