你已经派生过 gprMax
镜像自地址
https://gitee.com/sunhf/gprMax.git
已同步 2025-08-07 15:10:13 +08:00
Reformatted some code in many files where an f-string could have been used but was not used.
这个提交包含在:
@@ -52,7 +52,7 @@ class Cylinder(UserObjectGeometry):
|
||||
p2 = self.kwargs['p2']
|
||||
r = self.kwargs['r']
|
||||
except KeyError:
|
||||
logger.exception(self.__str__() + ' please specify 2 points and a radius')
|
||||
logger.exception(f'{self.__str__()} please specify 2 points and a radius')
|
||||
raise
|
||||
|
||||
# Check averaging
|
||||
@@ -72,7 +72,7 @@ class Cylinder(UserObjectGeometry):
|
||||
try:
|
||||
materialsrequested = self.kwargs['material_ids']
|
||||
except KeyError:
|
||||
logger.exception(self.__str__() + ' no materials have been specified')
|
||||
logger.exception(f'{self.__str__()} no materials have been specified')
|
||||
raise
|
||||
|
||||
p3 = uip.round_to_grid_static_point(p1)
|
||||
@@ -82,7 +82,7 @@ class Cylinder(UserObjectGeometry):
|
||||
x2, y2, z2 = uip.round_to_grid(p2)
|
||||
|
||||
if r <= 0:
|
||||
logger.exception(self.__str__() + f' the radius {r:g} should be a positive value.')
|
||||
logger.exception(f'{self.__str__()} the radius {r:g} should be a positive value.')
|
||||
raise ValueError
|
||||
|
||||
# Look up requested materials in existing list of material instances
|
||||
@@ -90,7 +90,7 @@ class Cylinder(UserObjectGeometry):
|
||||
|
||||
if len(materials) != len(materialsrequested):
|
||||
notfound = [x for x in materialsrequested if x not in materials]
|
||||
logger.exception(self.__str__() + f' material(s) {notfound} do not exist')
|
||||
logger.exception(f'{self.__str__()} material(s) {notfound} do not exist')
|
||||
raise ValueError
|
||||
|
||||
# Isotropic case
|
||||
@@ -130,7 +130,7 @@ class Cylinder(UserObjectGeometry):
|
||||
grid.rigidE, grid.rigidH, grid.ID)
|
||||
|
||||
dielectricsmoothing = 'on' if averaging else 'off'
|
||||
logger.info(self.grid_name(grid) + f"Cylinder with face centres {p3[0]:g}m, " +
|
||||
logger.info(f"{self.grid_name(grid)}Cylinder with face centres {p3[0]:g}m, " +
|
||||
f"{p3[1]:g}m, {p3[2]:g}m and {p4[0]:g}m, {p4[1]:g}m, {p4[2]:g}m, " +
|
||||
f"with radius {r:g}m, of material(s) {', '.join(materialsrequested)} " +
|
||||
f"created, dielectric smoothing is {dielectricsmoothing}.")
|
||||
|
@@ -181,14 +181,14 @@ class CylindricalSector(UserObjectGeometry):
|
||||
|
||||
if thickness > 0:
|
||||
dielectricsmoothing = 'on' if averaging else 'off'
|
||||
logger.info(self.grid_name(grid) + f"Cylindrical sector with centre " +
|
||||
logger.info(f"{self.grid_name(grid)}Cylindrical sector with centre " +
|
||||
f"{ctr1:g}m, {ctr2:g}m, radius {r:g}m, starting angle " +
|
||||
f"{(sectorstartangle / (2 * np.pi)) * 360:.1f} degrees, " +
|
||||
f"sector angle {(sectorangle / (2 * np.pi)) * 360:.1f} degrees, " +
|
||||
f"thickness {thickness:g}m, of material(s) {', '.join(materialsrequested)} " +
|
||||
f"created, dielectric smoothing is {dielectricsmoothing}.")
|
||||
else:
|
||||
logger.info(self.grid_name(grid) + f"Cylindrical sector with centre " +
|
||||
logger.info(f"{self.grid_name(grid)}Cylindrical sector with centre " +
|
||||
f"{ctr1:g}m, {ctr2:g}m, radius {r:g}m, starting angle " +
|
||||
f"{(sectorstartangle / (2 * np.pi)) * 360:.1f} degrees, " +
|
||||
f"sector angle {(sectorangle / (2 * np.pi)) * 360:.1f} " +
|
||||
|
@@ -83,11 +83,9 @@ class Edge(UserObjectGeometry):
|
||||
|
||||
# Check for valid orientations
|
||||
# x-orientated edge
|
||||
if (xs != xf
|
||||
and (ys != yf or zs != zf)
|
||||
or xs == xf
|
||||
and ys != yf
|
||||
and zs != zf):
|
||||
if ((xs != xf and (ys != yf or zs != zf))
|
||||
or (ys != yf and (xs != xf or zs != zf))
|
||||
or (zs != zf and (xs != xf or ys != yf))):
|
||||
logger.exception(f'{self.__str__()} the edge is not specified correctly')
|
||||
raise ValueError
|
||||
elif xs != xf:
|
||||
@@ -102,6 +100,6 @@ class Edge(UserObjectGeometry):
|
||||
for k in range(zs, zf):
|
||||
build_edge_z(xs, ys, k, material.numID, grid.rigidE, grid.rigidH, grid.ID)
|
||||
|
||||
logger.info(self.grid_name(grid) + f'Edge from {p3[0]:g}m, {p3[1]:g}m, ' +
|
||||
logger.info(f'{self.grid_name(grid)}Edge from {p3[0]:g}m, {p3[1]:g}m, ' +
|
||||
f'{p3[2]:g}m, to {p4[0]:g}m, {p4[1]:g}m, {p4[2]:g}m of ' +
|
||||
f'material {material_id} created.')
|
||||
|
@@ -126,7 +126,7 @@ class Ellipsoid(UserObjectGeometry):
|
||||
grid.rigidE, grid.rigidH, grid.ID)
|
||||
|
||||
dielectricsmoothing = 'on' if averaging else 'off'
|
||||
logger.info(self.grid_name(grid) + f"Ellipsoid with centre {p2[0]:g}m, " +
|
||||
logger.info(f"{self.grid_name(grid)}Ellipsoid with centre {p2[0]:g}m, " +
|
||||
f"{p2[1]:g}m, {p2[2]:g}m, x-semiaxis {xr:g}m, y-semiaxis {yr:g}m and z-semiaxis {zr:g}m of material(s) " +
|
||||
f"{', '.join(materialsrequested)} created, dielectric " +
|
||||
f"smoothing is {dielectricsmoothing}.")
|
||||
|
@@ -78,13 +78,13 @@ class FractalBox(UserObjectGeometry):
|
||||
mixing_model_id = self.kwargs['mixing_model_id']
|
||||
ID = self.kwargs['id']
|
||||
except KeyError:
|
||||
logger.exception(self.__str__() + ' Incorrect parameters')
|
||||
logger.exception(f'{self.__str__()} Incorrect parameters')
|
||||
raise
|
||||
|
||||
try:
|
||||
seed = self.kwargs['seed']
|
||||
except KeyError:
|
||||
logger.warning(self.__str__() + ' no value for seed detected. This ' +
|
||||
logger.warning(f'{self.__str__()} no value for seed detected. This ' +
|
||||
'means you will get a different fractal distribution ' +
|
||||
'every time the model runs.')
|
||||
seed = None
|
||||
@@ -107,24 +107,24 @@ class FractalBox(UserObjectGeometry):
|
||||
p1, p2 = uip.check_box_points(p1, p2, self.__str__())
|
||||
xs, ys, zs = p1
|
||||
xf, yf, zf = p2
|
||||
|
||||
|
||||
if frac_dim < 0:
|
||||
logger.exception(self.__str__() + ' requires a positive value for the ' +
|
||||
logger.exception(f'{self.__str__()} requires a positive value for the ' +
|
||||
'fractal dimension')
|
||||
raise ValueError
|
||||
if weighting[0] < 0:
|
||||
logger.exception(self.__str__() + ' requires a positive value for the ' +
|
||||
logger.exception(f'{self.__str__()} requires a positive value for the ' +
|
||||
'fractal weighting in the x direction')
|
||||
raise ValueError
|
||||
if weighting[1] < 0:
|
||||
logger.exception(self.__str__() + ' requires a positive value for the ' +
|
||||
logger.exception(f'{self.__str__()} requires a positive value for the ' +
|
||||
'fractal weighting in the y direction')
|
||||
raise ValueError
|
||||
if weighting[2] < 0:
|
||||
logger.exception(self.__str__() + ' requires a positive value for the ' +
|
||||
logger.exception(f'{self.__str__()} requires a positive value for the ' +
|
||||
'fractal weighting in the z direction')
|
||||
if n_materials < 0:
|
||||
logger.exception(self.__str__() + ' requires a positive value for the ' +
|
||||
logger.exception(f'{self.__str__()} requires a positive value for the ' +
|
||||
'number of bins')
|
||||
raise ValueError
|
||||
|
||||
@@ -136,14 +136,14 @@ class FractalBox(UserObjectGeometry):
|
||||
|
||||
if mixingmodel:
|
||||
if nbins == 1:
|
||||
logger.exception(self.__str__() + ' must be used with more than ' +
|
||||
logger.exception(f'{self.__str__()} must be used with more than ' +
|
||||
'one material from the mixing model.')
|
||||
raise ValueError
|
||||
# Create materials from mixing model as number of bins now known
|
||||
# from fractal_box command.
|
||||
mixingmodel.calculate_properties(nbins, grid)
|
||||
elif not material:
|
||||
logger.exception(self.__str__() + f' mixing model or material with ' +
|
||||
logger.exception(f'{self.__str__()} mixing model or material with ' +
|
||||
'ID {mixing_model_id} does not exist')
|
||||
raise ValueError
|
||||
|
||||
|
@@ -319,7 +319,7 @@ class FractalBoxBuilder(UserObjectGeometry):
|
||||
|
||||
else:
|
||||
if volume.nbins == 1:
|
||||
logger.exception(self.__str__() + ' is being used with a ' +
|
||||
logger.exception(f'{self.__str__()} is being used with a ' +
|
||||
'single material and no modifications, ' +
|
||||
'therefore please use a #box command instead.')
|
||||
raise ValueError
|
||||
|
@@ -122,7 +122,7 @@ class GeometryObjectsRead(UserObjectGeometry):
|
||||
grid.rigidE[:, xs:xs + rigidE.shape[1], ys:ys + rigidE.shape[2], zs:zs + rigidE.shape[3]] = rigidE
|
||||
grid.rigidH[:, xs:xs + rigidH.shape[1], ys:ys + rigidH.shape[2], zs:zs + rigidH.shape[3]] = rigidH
|
||||
grid.ID[:, xs:xs + ID.shape[1], ys:ys + ID.shape[2], zs:zs + ID.shape[3]] = ID + numexistmaterials
|
||||
logger.info(self.grid_name(grid) + f'Geometry objects from file {geofile} ' +
|
||||
logger.info(f'{self.grid_name(grid)}Geometry objects from file {geofile} ' +
|
||||
f'inserted at {xs * grid.dx:g}m, {ys * grid.dy:g}m, ' +
|
||||
f'{zs * grid.dz:g}m, with corresponding materials file ' +
|
||||
f'{matfile}.')
|
||||
@@ -131,7 +131,7 @@ class GeometryObjectsRead(UserObjectGeometry):
|
||||
build_voxels_from_array(xs, ys, zs, config.get_model_config().ompthreads,
|
||||
numexistmaterials, averaging, data,
|
||||
grid.solid, grid.rigidE, grid.rigidH, grid.ID)
|
||||
logger.info(self.grid_name(grid) + f'Geometry objects from file ' +
|
||||
logger.info(f'{self.grid_name(grid)}Geometry objects from file ' +
|
||||
f'(voxels only){geofile} inserted at {xs * grid.dx:g}m, ' +
|
||||
f'{ys * grid.dy:g}m, {zs * grid.dz:g}m, with corresponding ' +
|
||||
f'materials file {matfile}.')
|
||||
|
@@ -86,14 +86,9 @@ class Plate(UserObjectGeometry):
|
||||
xf, yf, zf = p2
|
||||
|
||||
# Check for valid orientations
|
||||
if (xs == xf
|
||||
and (ys == yf or zs == zf)
|
||||
or (xs != xf
|
||||
and ys == yf
|
||||
and zs == zf)
|
||||
or (xs != xf
|
||||
and ys != yf
|
||||
and zs != zf)):
|
||||
if ((xs == xf and (ys == yf or zs == zf))
|
||||
or (ys == yf and (xs == xf or zs == zf))
|
||||
or (zs == zf and (ys != yf and xs != xf))):
|
||||
logger.exception(f'{self.__str__()} the plate is not specified correctly')
|
||||
raise ValueError
|
||||
|
||||
@@ -153,6 +148,6 @@ class Plate(UserObjectGeometry):
|
||||
build_face_xy(i, j, zs, numIDx, numIDy, grid.rigidE,
|
||||
grid.rigidH, grid.ID)
|
||||
|
||||
logger.info(self.grid_name(grid) + f"Plate from {p3[0]:g}m, {p3[1]:g}m, " +
|
||||
logger.info(f"{self.grid_name(grid)}Plate from {p3[0]:g}m, {p3[1]:g}m, " +
|
||||
f"{p3[2]:g}m, to {p4[0]:g}m, {p4[1]:g}m, {p4[2]:g}m of " +
|
||||
f"material(s) {', '.join(materialsrequested)} created.")
|
||||
|
@@ -125,7 +125,7 @@ class Sphere(UserObjectGeometry):
|
||||
grid.rigidE, grid.rigidH, grid.ID)
|
||||
|
||||
dielectricsmoothing = 'on' if averaging else 'off'
|
||||
logger.info(self.grid_name(grid) + f"Sphere with centre {p2[0]:g}m, " +
|
||||
logger.info(f"{self.grid_name(grid)}Sphere with centre {p2[0]:g}m, " +
|
||||
f"{p2[1]:g}m, {p2[2]:g}m, radius {r:g}m, of material(s) " +
|
||||
f"{', '.join(materialsrequested)} created, dielectric " +
|
||||
f"smoothing is {dielectricsmoothing}.")
|
||||
|
@@ -185,13 +185,13 @@ class Triangle(UserObjectGeometry):
|
||||
|
||||
if thickness > 0:
|
||||
dielectricsmoothing = 'on' if averaging else 'off'
|
||||
logger.info(self.grid_name(grid) + f"Triangle with coordinates " +
|
||||
logger.info(f"{self.grid_name(grid)}Triangle with coordinates " +
|
||||
f"{p4[0]:g}m {p4[1]:g}m {p4[2]:g}m, {p5[0]:g}m {p5[1]:g}m " +
|
||||
f"{p5[2]:g}m, {p6[0]:g}m {p6[1]:g}m {p6[2]:g}m and thickness " +
|
||||
f"{thickness:g}m of material(s) {', '.join(materialsrequested)} " +
|
||||
f"created, dielectric smoothing is {dielectricsmoothing}.")
|
||||
else:
|
||||
logger.info(self.grid_name(grid) + f"Triangle with coordinates " +
|
||||
logger.info(f"{self.grid_name(grid)}Triangle with coordinates " +
|
||||
f"{p4[0]:g}m {p4[1]:g}m {p4[2]:g}m, {p5[0]:g}m {p5[1]:g}m " +
|
||||
f"{p5[2]:g}m, {p6[0]:g}m {p6[1]:g}m {p6[2]:g}m of material(s) " +
|
||||
f"{', '.join(materialsrequested)} created.")
|
||||
|
在新工单中引用
屏蔽一个用户