reformat code using python-lsp-ruff

This commit is contained in:
2024-07-01 15:21:52 +02:00
parent 271ecbb631
commit 5a62fa4983
13 changed files with 1271 additions and 860 deletions

View File

@@ -1,10 +1,11 @@
import numpy as np
def rot2D(ang):
"""
Return the 2D rotation matrix of given angle in degrees
"""
alpha = np.pi*ang/180
alpha = np.pi * ang / 180
return np.array([[np.cos(alpha), np.sin(alpha)], [-np.sin(alpha), np.cos(alpha)]])
@@ -17,10 +18,10 @@ def princ_angle(ang):
A = np.array([ang])
else:
A = np.array(ang)
while np.any(A < 0.):
A[A < 0.] = A[A < 0.]+360.
while np.any(A >= 180.):
A[A >= 180.] = A[A >= 180.]-180.
while np.any(A < 0.0):
A[A < 0.0] = A[A < 0.0] + 360.0
while np.any(A >= 180.0):
A[A >= 180.0] = A[A >= 180.0] - 180.0
if type(ang) is type(A):
return A
else:
@@ -31,16 +32,16 @@ def sci_not(v, err, rnd=1, out=str):
"""
Return the scientifque error notation as a string.
"""
power = - int(('%E' % v)[-3:])+1
output = [r"({0}".format(round(v*10**power, rnd)), round(v*10**power, rnd)]
power = -int(("%E" % v)[-3:]) + 1
output = [r"({0}".format(round(v * 10**power, rnd)), round(v * 10**power, rnd)]
if isinstance(err, list):
for error in err:
output[0] += r" $\pm$ {0}".format(round(error*10**power, rnd))
output.append(round(error*10**power, rnd))
output[0] += r" $\pm$ {0}".format(round(error * 10**power, rnd))
output.append(round(error * 10**power, rnd))
else:
output[0] += r" $\pm$ {0}".format(round(err*10**power, rnd))
output.append(round(err*10**power, rnd))
output[0] += r" $\pm$ {0}".format(round(err * 10**power, rnd))
output.append(round(err * 10**power, rnd))
if out == str:
return output[0]+r")e{0}".format(-power)
return output[0] + r")e{0}".format(-power)
else:
return *output[1:], -power