def perturb(self, distance):
        """
        Performs a random perturbation of the sites in a structure to break
        symmetries.

        Args:
            distance (float): Distance in angstroms by which to perturb each
                site.
        """

        def get_rand_vec():
            # deals with zero vectors.
            vector = np.random.randn(3)
            vnorm = np.linalg.norm(vector)
            return vector / vnorm * distance if vnorm != 0 else get_rand_vec()

        for i in range(len(self._sites)):
            self.translate_sites([i], get_rand_vec(), frac_coords=False)
def perturb ( self , distance ) : def get_rand_vec ( ) : vector = np . random . randn ( 3 ) vnorm = np . linalg . norm ( vector ) return vector / vnorm * distance if vnorm != 0 else get_rand_vec ( ) for i in range ( len ( self . _sites ) ) : self . translate_sites ( [ i ] , get_rand_vec ( ) , frac_coords = False )
Performs a random perturbation of the sites in a structure to break
        symmetries.

        Args:
            distance (float): Distance in angstroms by which to perturb each
                site.