def from_xyz_string(xyz_string):
        """
        Args:
            xyz_string: string of the form 'x, y, z', '-x, -y, z',
                '-2y+1/2, 3x+1/2, z-y+1/2', etc.
        Returns:
            SymmOp
        """
        rot_matrix = np.zeros((3, 3))
        trans = np.zeros(3)
        toks = xyz_string.strip().replace(" ", "").lower().split(",")
        re_rot = re.compile(r"([+-]?)([\d\.]*)/?([\d\.]*)([x-z])")
        re_trans = re.compile(r"([+-]?)([\d\.]+)/?([\d\.]*)(?![x-z])")
        for i, tok in enumerate(toks):
            # build the rotation matrix
            for m in re_rot.finditer(tok):
                factor = -1 if m.group(1) == "-" else 1
                if m.group(2) != "":
                    factor *= float(m.group(2)) / float(m.group(3)) \
                        if m.group(3) != "" else float(m.group(2))
                j = ord(m.group(4)) - 120
                rot_matrix[i, j] = factor
            # build the translation vector
            for m in re_trans.finditer(tok):
                factor = -1 if m.group(1) == "-" else 1
                num = float(m.group(2)) / float(m.group(3)) \
                    if m.group(3) != "" else float(m.group(2))
                trans[i] = num * factor
        return SymmOp.from_rotation_and_translation(rot_matrix, trans)
def from_xyz_string ( xyz_string ) : rot_matrix = np . zeros ( ( 3 , 3 ) ) trans = np . zeros ( 3 ) toks = xyz_string . strip ( ) . replace ( " " , "" ) . lower ( ) . split ( "," ) re_rot = re . compile ( r"([+-]?)([\d\.]*)/?([\d\.]*)([x-z])" ) re_trans = re . compile ( r"([+-]?)([\d\.]+)/?([\d\.]*)(?![x-z])" ) for i , tok in enumerate ( toks ) : for m in re_rot . finditer ( tok ) : factor = - 1 if m . group ( 1 ) == "-" else 1 if m . group ( 2 ) != "" : factor *= float ( m . group ( 2 ) ) / float ( m . group ( 3 ) ) if m . group ( 3 ) != "" else float ( m . group ( 2 ) ) j = ord ( m . group ( 4 ) ) - 120 rot_matrix [ i , j ] = factor for m in re_trans . finditer ( tok ) : factor = - 1 if m . group ( 1 ) == "-" else 1 num = float ( m . group ( 2 ) ) / float ( m . group ( 3 ) ) if m . group ( 3 ) != "" else float ( m . group ( 2 ) ) trans [ i ] = num * factor return SymmOp . from_rotation_and_translation ( rot_matrix , trans )
Args:
            xyz_string: string of the form 'x, y, z', '-x, -y, z',
                '-2y+1/2, 3x+1/2, z-y+1/2', etc.
        Returns:
            SymmOp