code: def vec2pix(nside, x, y, z, nest=False):
      
      theta, phi = vec2ang(np.transpose([x, y, z]))
      # hp.vec2ang() returns raveled arrays, which are 1D.
      if np.isscalar(x):
          theta = theta.item()
          phi = phi.item()
      else:
          shape = np.shape(x)
          theta = theta.reshape(shape)
          phi = phi.reshape(shape)
      lon, lat = _healpy_to_lonlat(theta, phi)
      return lonlat_to_healpix(lon, lat, nside, order='nested' if nest else 'ring')
docs: Drop-in replacement for healpy `~healpy.pixelfunc.vec2pix`.