Updated with ruff formatter

这个提交包含在:
Craig Warren
2025-02-04 20:38:27 +00:00
父节点 e2c5a23f28
当前提交 548a0a550c
共有 70 个文件被更改,包括 3601 次插入982 次删除

查看文件

@@ -90,13 +90,19 @@ for i, model in enumerate(testmodels):
# Arrays for storing time
float_or_double = filetest[path + outputstest[0]].dtype
timetest = (
np.linspace(0, (filetest.attrs["Iterations"] - 1) * filetest.attrs["dt"], num=filetest.attrs["Iterations"])
np.linspace(
0,
(filetest.attrs["Iterations"] - 1) * filetest.attrs["dt"],
num=filetest.attrs["Iterations"],
)
/ 1e-9
)
timeref = timetest
# Arrays for storing field data
datatest = np.zeros((filetest.attrs["Iterations"], len(outputstest)), dtype=float_or_double)
datatest = np.zeros(
(filetest.attrs["Iterations"], len(outputstest)), dtype=float_or_double
)
for ID, name in enumerate(outputstest):
datatest[:, ID] = filetest[path + str(name)][:]
if np.any(np.isnan(datatest[:, ID])):
@@ -106,11 +112,18 @@ for i, model in enumerate(testmodels):
# Tx/Rx position to feed to analytical solution
rxpos = filetest[path].attrs["Position"]
txpos = filetest["/srcs/src1/"].attrs["Position"]
rxposrelative = ((rxpos[0] - txpos[0]), (rxpos[1] - txpos[1]), (rxpos[2] - txpos[2]))
rxposrelative = (
(rxpos[0] - txpos[0]),
(rxpos[1] - txpos[1]),
(rxpos[2] - txpos[2]),
)
# Analytical solution of a dipole in free space
dataref = hertzian_dipole_fs(
filetest.attrs["Iterations"], filetest.attrs["dt"], filetest.attrs["dx_dy_dz"], rxposrelative
filetest.attrs["Iterations"],
filetest.attrs["dt"],
filetest.attrs["dx_dy_dz"],
rxposrelative,
)
filetest.close()
@@ -143,18 +156,30 @@ for i, model in enumerate(testmodels):
# Arrays for storing time
timeref = np.zeros((fileref.attrs["Iterations"]), dtype=float_or_doubleref)
timeref = (
np.linspace(0, (fileref.attrs["Iterations"] - 1) * fileref.attrs["dt"], num=fileref.attrs["Iterations"])
np.linspace(
0,
(fileref.attrs["Iterations"] - 1) * fileref.attrs["dt"],
num=fileref.attrs["Iterations"],
)
/ 1e-9
)
timetest = np.zeros((filetest.attrs["Iterations"]), dtype=float_or_doubletest)
timetest = (
np.linspace(0, (filetest.attrs["Iterations"] - 1) * filetest.attrs["dt"], num=filetest.attrs["Iterations"])
np.linspace(
0,
(filetest.attrs["Iterations"] - 1) * filetest.attrs["dt"],
num=filetest.attrs["Iterations"],
)
/ 1e-9
)
# Arrays for storing field data
dataref = np.zeros((fileref.attrs["Iterations"], len(outputsref)), dtype=float_or_doubleref)
datatest = np.zeros((filetest.attrs["Iterations"], len(outputstest)), dtype=float_or_doubletest)
dataref = np.zeros(
(fileref.attrs["Iterations"], len(outputsref)), dtype=float_or_doubleref
)
datatest = np.zeros(
(filetest.attrs["Iterations"], len(outputstest)), dtype=float_or_doubletest
)
for ID, name in enumerate(outputsref):
dataref[:, ID] = fileref[path + str(name)][:]
datatest[:, ID] = filetest[path + str(name)][:]
@@ -170,7 +195,10 @@ for i, model in enumerate(testmodels):
for i in range(len(outputstest)):
maxi = np.amax(np.abs(dataref[:, i]))
datadiffs[:, i] = np.divide(
np.abs(dataref[:, i] - datatest[:, i]), maxi, out=np.zeros_like(dataref[:, i]), where=maxi != 0
np.abs(dataref[:, i] - datatest[:, i]),
maxi,
out=np.zeros_like(dataref[:, i]),
where=maxi != 0,
) # Replace any division by zero with zero
# Calculate power (ignore warning from taking a log of any zero values)
@@ -260,8 +288,20 @@ for i, model in enumerate(testmodels):
# bbox_inches='tight', pad_inches=0.1)
# fig2.savefig(savediffs.with_suffix('.pdf'), dpi=None, format='pdf',
# bbox_inches='tight', pad_inches=0.1)
fig1.savefig(file.with_suffix(".png"), dpi=150, format="png", bbox_inches="tight", pad_inches=0.1)
fig2.savefig(filediffs.with_suffix(".png"), dpi=150, format="png", bbox_inches="tight", pad_inches=0.1)
fig1.savefig(
file.with_suffix(".png"),
dpi=150,
format="png",
bbox_inches="tight",
pad_inches=0.1,
)
fig2.savefig(
filediffs.with_suffix(".png"),
dpi=150,
format="png",
bbox_inches="tight",
pad_inches=0.1,
)
# Summary of results
for name, data in sorted(testresults.items()):