Skip to content

Commit

Permalink
Merge pull request #1263 from nschloe/warn-fixes
Browse files Browse the repository at this point in the history
warn fixes
  • Loading branch information
nschloe authored Jan 19, 2022
2 parents a6175e0 + db7cd8d commit 627cff0
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 18 deletions.
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[metadata]
name = meshio
version = 5.2.2
version = 5.2.3
author = Nico Schlömer et al.
author_email = [email protected]
description = I/O for many mesh formats
Expand Down
1 change: 0 additions & 1 deletion src/meshio/_cli/_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ def main(argv=None):
)

parser = subparsers.add_parser("convert", help="Convert mesh files", aliases=["c"])

_convert.add_args(parser)
parser.set_defaults(func=_convert.convert)

Expand Down
7 changes: 3 additions & 4 deletions src/meshio/ansys/_ansys.py
Original file line number Diff line number Diff line change
Expand Up @@ -365,15 +365,14 @@ def read(filename): # noqa: C901
obj = re.match("\\(45 \\([0-9]+ ([\\S]+) ([\\S]+)\\)\\(\\)\\)", line)
if obj:
warn(
"Zone specification not supported yet (%r, %r). " "Skipping.",
obj.group(1),
obj.group(2),
f"Zone specification not supported yet ({obj.group(1)}, {obj.group(2)}). "
+ "Skipping.",
)
else:
warn("Zone specification not supported yet.")

else:
warn("Unknown index %r. Skipping.", index)
warn(f"Unknown index {index}. Skipping.")
# Skipping ahead to the next line with two closing brackets.
_skip_close(f, line.count("(") - line.count(")"))

Expand Down
6 changes: 2 additions & 4 deletions src/meshio/dolfin/_dolfin.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def _read_mesh(filename):
assert cell_tags is not None
cells[0][1][k] = [elem.attrib[t] for t in cell_tags]
else:
warn("Unknown entry %s. Ignoring.", elem.tag)
warn(f"Unknown entry {elem.tag}. Ignoring.")

elem.clear()

Expand Down Expand Up @@ -140,9 +140,7 @@ def _write_mesh(filename, points, cell_type, cells):
discarded_cell_types = {c.type for c in cells if c.type != cell_type}
warn(
"DOLFIN XML can only handle one cell type at a time. "
"Using %s, discarding %s.",
cell_type,
", ".join(discarded_cell_types),
+ f"Using {cell_type}, discarding {', '.join(discarded_cell_types)}.",
)

dim = points.shape[1]
Expand Down
6 changes: 3 additions & 3 deletions src/meshio/vtk/_vtk_42.py
Original file line number Diff line number Diff line change
Expand Up @@ -605,7 +605,7 @@ def pad(array):
if mesh.points.shape[1] == 2:
warn(
"VTK requires 3D points, but 2D points given. "
"Appending 0 third component."
+ "Appending 0 third component."
)
points = pad(mesh.points)
else:
Expand All @@ -616,7 +616,7 @@ def pad(array):
if len(values.shape) == 2 and values.shape[1] == 2:
warn(
"VTK requires 3D vectors, but 2D vectors given. "
"Appending 0 third component to {}.".format(name)
+ f"Appending 0 third component to {name}."
)
mesh.point_data[name] = pad(values)

Expand All @@ -625,7 +625,7 @@ def pad(array):
if len(values.shape) == 2 and values.shape[1] == 2:
warn(
"VTK requires 3D vectors, but 2D vectors given. "
"Appending 0 third component to {}.".format(name)
+ f"Appending 0 third component to {name}."
)
data[k] = pad(data[k])

Expand Down
8 changes: 3 additions & 5 deletions src/meshio/xdmf/time_series.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ def __init__(self, filename, data_format: str = "HDF") -> None:
ET.register_namespace("xi", "https://www.w3.org/2001/XInclude/")

self.has_mesh = False
self.mesh_name = None
self.mesh_name = "mesh"

def __enter__(self):
if self.data_format == "HDF":
Expand Down Expand Up @@ -284,7 +284,6 @@ def write_points_cells(
# <DataItem Dimensions="8457 2" Format="HDF">maxwell.h5:/Mesh/0/mesh/geometry</DataItem>
# </Geometry>
# </Grid>
self.mesh_name = "mesh"
grid = ET.SubElement(
self.domain, "Grid", Name=self.mesh_name, GridType="Uniform"
)
Expand Down Expand Up @@ -388,18 +387,17 @@ def cells(
NumberOfElements=str(num_cells),
)
dt, prec = numpy_to_xdmf_dtype[cell_blocks[0].data.dtype.name]
dim = "{} {}".format(*cell_blocks[0].data.shape)
data_item = ET.SubElement(
topo,
"DataItem",
DataType=dt,
Dimensions=dim,
Dimensions="{} {}".format(*cell_blocks[0].data.shape),
Format=self.data_format,
Precision=prec,
)
data_item.text = self.numpy_to_xml_string(cell_blocks[0].data)
elif len(cell_blocks) > 1:
total_num_cells = sum(c.data.shape[0] for c in cell_blocks)
total_num_cells = sum(len(c.data) for c in cell_blocks)
topo = ET.SubElement(
grid,
"Topology",
Expand Down

0 comments on commit 627cff0

Please sign in to comment.