diff --git a/src/femagtools/me.py b/src/femagtools/me.py index 6b940bc6..f2c823af 100644 --- a/src/femagtools/me.py +++ b/src/femagtools/me.py @@ -3,8 +3,8 @@ """ __author__ = 'dapu zhang' -import re -import numpy as np +import re +import numpy as np import matplotlib.pyplot as plt import logging @@ -16,33 +16,33 @@ def get_eigenvectors(filelist, psfiles): eigenvecs = {} eigenfreq = [] ps_data = [] - temp = [] + temp = [] temp_arr = [] read_fig = False if len(psfiles) > 0: read_fig = True if len(filelist) == 0: return [] - - for k, kk in zip(filelist, range(len(filelist))): + + for k, kk in zip(filelist, range(len(filelist))): # read ps file if read_fig: ps_data.append(plt.imread(psfiles[kk])) eigenvecs[str(kk)] = {} - with open(k, 'r') as f: + with open(k, 'r') as f: data = f.read().split('\n') - eigenval = float(re.split('\s+', data[0].strip())[2]) + eigenval = float(re.split(r'\s+', data[0].strip())[2]) eigenfreq.append(eigenval/2/np.pi) - - for i in range(len(data[1:-1])): - for j in data[2+i].strip().split(' '): + + for i in range(len(data[1:-1])): + for j in data[2+i].strip().split(' '): if j != '': temp.append(float(j)) temp_arr = np.array(temp).reshape(-1, 5) idx_collect = [] # remove the index, at which the dof equals zero - for c in range(temp_arr.shape[0]): + for c in range(temp_arr.shape[0]): if np.abs(temp_arr[c, 1]) < 1e-15 and \ - np.abs(temp_arr[c, 2]) < 1e-15: + np.abs(temp_arr[c, 2]) < 1e-15: idx_collect.append(c) # prepare the data from the further calculation temp_arr = np.delete(temp_arr, np.array(idx_collect), axis=0) @@ -52,4 +52,4 @@ def get_eigenvectors(filelist, psfiles): # return node position if kk == 0: eigenvecs.update({'node_pos': temp_arr[:, 4::]}) - return [ps_data, eigenfreq, eigenvecs] \ No newline at end of file + return [ps_data, eigenfreq, eigenvecs] diff --git a/src/femagtools/plot/fieldlines.py b/src/femagtools/plot/fieldlines.py index 8b5fae74..8526091e 100644 --- a/src/femagtools/plot/fieldlines.py +++ b/src/femagtools/plot/fieldlines.py @@ -4,7 +4,7 @@ import numpy as np import matplotlib.lines as mpl -rgbpat = re.compile('rgb\((\d+),(\d+),(\d+)\)') +rgbpat = re.compile(r'rgb\((\d+),(\d+),(\d+)\)') def fieldlines(svgfilename, ax=0): """plot fieldlines from svg file"""