This if separate the scalar case ( len(all_code)==1 ) and 1d case.