From 0fe8357c0f78ccb65e5bae9aeff01d8bc9864816 Mon Sep 17 00:00:00 2001 From: shimwell Date: Sat, 13 Apr 2024 23:21:57 +0000 Subject: [PATCH] [skip ci] Apply formatting changes --- examples/surface_mesh/cadquery_compound.py | 11 ++----- .../create_stp_files_for_examples.py | 7 +---- .../surface_mesh/multiple_cadquery_objects.py | 4 +-- examples/surface_mesh/single_stp_file.py | 7 +---- ...ed_cadquery_object_to_dagmc_volume_mesh.py | 4 +-- ...te_unstrucutred_volume_mesh_with_openmc.py | 4 +-- src/cad_to_dagmc/core.py | 29 +++++-------------- tests/test_file_creation.py | 26 ++++------------- 8 files changed, 19 insertions(+), 73 deletions(-) diff --git a/examples/surface_mesh/cadquery_compound.py b/examples/surface_mesh/cadquery_compound.py index 73bef6e..1ecf073 100644 --- a/examples/surface_mesh/cadquery_compound.py +++ b/examples/surface_mesh/cadquery_compound.py @@ -17,19 +17,12 @@ cq_shape_1 = r.extrude(-1) s2 = cq.Workplane("XY") -r2 = ( - s2.lineTo(3.0, 0) - .lineTo(3.0, 1.0) - .spline(spline_points, includeCurrent=True) - .close() -) +r2 = s2.lineTo(3.0, 0).lineTo(3.0, 1.0).spline(spline_points, includeCurrent=True).close() cq_shape_2 = r2.extrude(1) compound_of_shapes = cq.Compound.makeCompound([cq_shape_1.val(), cq_shape_2.val()]) my_model = CadToDagmc() -my_model.add_cadquery_object( - cadquery_object=compound_of_shapes, material_tags=["mat1", "mat2"] -) +my_model.add_cadquery_object(cadquery_object=compound_of_shapes, material_tags=["mat1", "mat2"]) my_model.export_dagmc_h5m_file(max_mesh_size=0.2, min_mesh_size=0.1) diff --git a/examples/surface_mesh/create_stp_files_for_examples.py b/examples/surface_mesh/create_stp_files_for_examples.py index 0a9cf8e..f001e02 100644 --- a/examples/surface_mesh/create_stp_files_for_examples.py +++ b/examples/surface_mesh/create_stp_files_for_examples.py @@ -46,12 +46,7 @@ (0.5, 1.0), (0, 1.0), ] -r = ( - result.lineTo(3.0, 0) - .lineTo(3.0, 1.0) - .spline(spline_points, includeCurrent=True) - .close() -) +r = result.lineTo(3.0, 0).lineTo(3.0, 1.0).spline(spline_points, includeCurrent=True).close() result = r.extrude(1.5) assembly = Assembly() assembly.add(result) diff --git a/examples/surface_mesh/multiple_cadquery_objects.py b/examples/surface_mesh/multiple_cadquery_objects.py index e8cc3a4..5e9e357 100644 --- a/examples/surface_mesh/multiple_cadquery_objects.py +++ b/examples/surface_mesh/multiple_cadquery_objects.py @@ -8,7 +8,5 @@ my_model = CadToDagmc() my_model.add_cadquery_object(cadquery_object=box, material_tags=["mat1"]) -my_model.add_cadquery_object( - cadquery_object=box_with_round_corners, material_tags=["mat2"] -) +my_model.add_cadquery_object(cadquery_object=box_with_round_corners, material_tags=["mat2"]) my_model.export_dagmc_h5m_file() diff --git a/examples/surface_mesh/single_stp_file.py b/examples/surface_mesh/single_stp_file.py index a7c83d9..14fed35 100644 --- a/examples/surface_mesh/single_stp_file.py +++ b/examples/surface_mesh/single_stp_file.py @@ -12,12 +12,7 @@ (0.5, 1.0), (0, 1.0), ] -r = ( - result.lineTo(3.0, 0) - .lineTo(3.0, 1.0) - .spline(spline_points, includeCurrent=True) - .close() -) +r = result.lineTo(3.0, 0).lineTo(3.0, 1.0).spline(spline_points, includeCurrent=True).close() result = r.extrude(1.5) assembly = cq.Assembly() assembly.add(result) diff --git a/examples/unstrucutred_volume_mesh/curved_cadquery_object_to_dagmc_volume_mesh.py b/examples/unstrucutred_volume_mesh/curved_cadquery_object_to_dagmc_volume_mesh.py index dc21e98..a6b7d6b 100644 --- a/examples/unstrucutred_volume_mesh/curved_cadquery_object_to_dagmc_volume_mesh.py +++ b/examples/unstrucutred_volume_mesh/curved_cadquery_object_to_dagmc_volume_mesh.py @@ -59,6 +59,4 @@ def gear(t, r1=4, r2=1): my_model.add_cadquery_object(result) my_model.add_cadquery_object(result2) -my_model.export_unstructured_mesh_file( - filename="umesh.h5m", max_mesh_size=1, min_mesh_size=0.1 -) +my_model.export_unstructured_mesh_file(filename="umesh.h5m", max_mesh_size=1, min_mesh_size=0.1) diff --git a/examples/unstrucutred_volume_mesh/simulate_unstrucutred_volume_mesh_with_openmc.py b/examples/unstrucutred_volume_mesh/simulate_unstrucutred_volume_mesh_with_openmc.py index 995c396..b965078 100644 --- a/examples/unstrucutred_volume_mesh/simulate_unstrucutred_volume_mesh_with_openmc.py +++ b/examples/unstrucutred_volume_mesh/simulate_unstrucutred_volume_mesh_with_openmc.py @@ -65,7 +65,5 @@ centroids = umesh_from_sp.centroids mesh_vols = umesh_from_sp.volumes -flux_mean = tally_result.get_values(scores=["flux"], value="mean").reshape( - umesh_from_sp.dimension -) +flux_mean = tally_result.get_values(scores=["flux"], value="mean").reshape(umesh_from_sp.dimension) umesh_from_sp.write_data_to_vtk(filename="tally.vtk", datasets={"mean": flux_mean}) diff --git a/src/cad_to_dagmc/core.py b/src/cad_to_dagmc/core.py index 81a8228..6bf8ebb 100644 --- a/src/cad_to_dagmc/core.py +++ b/src/cad_to_dagmc/core.py @@ -66,9 +66,7 @@ def _vertices_to_h5m( typing.Iterable[typing.Tuple[float, float, float]], typing.Iterable["cadquery.occ_impl.geom.Vector"], ], - triangles_by_solid_by_face: typing.Iterable[ - typing.Iterable[typing.Tuple[int, int, int]] - ], + triangles_by_solid_by_face: typing.Iterable[typing.Iterable[typing.Tuple[int, int, int]]], material_tags: typing.Iterable[str], h5m_filename="dagmc.h5m", implicit_complement_material_tag=None, @@ -88,11 +86,7 @@ def _vertices_to_h5m( raise ValueError(msg) # limited attribute checking to see if user passed in a list of CadQuery vectors - if ( - hasattr(vertices[0], "x") - and hasattr(vertices[0], "y") - and hasattr(vertices[0], "z") - ): + if hasattr(vertices[0], "x") and hasattr(vertices[0], "y") and hasattr(vertices[0], "z"): vertices_floats = [] for vert in vertices: vertices_floats.append((vert.x, vert.y, vert.z)) @@ -142,9 +136,7 @@ def _vertices_to_h5m( if len(face_ids_with_solid_ids[face_id]) == 2: other_solid_id = face_ids_with_solid_ids[face_id][1] other_volume_set = volume_sets_by_solid_id[other_solid_id] - sense_data = np.array( - [other_volume_set, volume_set], dtype="uint64" - ) + sense_data = np.array([other_volume_set, volume_set], dtype="uint64") else: sense_data = np.array([volume_set, 0], dtype="uint64") @@ -283,8 +275,7 @@ def mesh_to_vertices_and_triangles( for nodeTag in nodeTags: shifted_node_tags.append(nodeTag - 1) grouped_node_tags = [ - shifted_node_tags[i : i + n] - for i in range(0, len(shifted_node_tags), n) + shifted_node_tags[i : i + n] for i in range(0, len(shifted_node_tags), n) ] nodes_in_each_surface[surface] = grouped_node_tags triangles_by_solid_by_face[vol_id] = nodes_in_each_surface @@ -426,9 +417,7 @@ def add_stp_file( scaled_part = part else: scaled_part = part.scale(scale_factor) - self.add_cadquery_object( - cadquery_object=scaled_part, material_tags=material_tags - ) + self.add_cadquery_object(cadquery_object=scaled_part, material_tags=material_tags) def add_cadquery_object( self, @@ -452,9 +441,7 @@ def add_cadquery_object( if isinstance(cadquery_object, cq.assembly.Assembly): cadquery_object = cadquery_object.toCompound() - if isinstance( - cadquery_object, (cq.occ_impl.shapes.Compound, cq.occ_impl.shapes.Solid) - ): + if isinstance(cadquery_object, (cq.occ_impl.shapes.Compound, cq.occ_impl.shapes.Solid)): iterable_solids = cadquery_object.Solids() else: iterable_solids = cadquery_object.val().Solids() @@ -565,9 +552,7 @@ def export_dagmc_h5m_file( for part in self.parts: assembly.add(part) - imprinted_assembly, imprinted_solids_with_org_id = cq.occ_impl.assembly.imprint( - assembly - ) + imprinted_assembly, imprinted_solids_with_org_id = cq.occ_impl.assembly.imprint(assembly) original_ids = _get_ids_from_assembly(assembly) scrambled_ids = _get_ids_from_imprinted_assembly(imprinted_solids_with_org_id) diff --git a/tests/test_file_creation.py b/tests/test_file_creation.py index c2aa852..bcbad59 100644 --- a/tests/test_file_creation.py +++ b/tests/test_file_creation.py @@ -142,26 +142,14 @@ def test_cq_compound(): ] s = cq.Workplane("XY") - r = ( - s.lineTo(3.0, 0) - .lineTo(3.0, 1.0) - .spline(spline_points, includeCurrent=True) - .close() - ) + r = s.lineTo(3.0, 0).lineTo(3.0, 1.0).spline(spline_points, includeCurrent=True).close() cq_shape_1 = r.extrude(-1) s2 = cq.Workplane("XY") - r2 = ( - s2.lineTo(3.0, 0) - .lineTo(3.0, 1.0) - .spline(spline_points, includeCurrent=True) - .close() - ) + r2 = s2.lineTo(3.0, 0).lineTo(3.0, 1.0).spline(spline_points, includeCurrent=True).close() cq_shape_2 = r2.extrude(1) - compound_of_workplanes = cq.Compound.makeCompound( - [cq_shape_1.val(), cq_shape_2.val()] - ) + compound_of_workplanes = cq.Compound.makeCompound([cq_shape_1.val(), cq_shape_2.val()]) my_model = CadToDagmc() my_model.add_cadquery_object( @@ -216,9 +204,7 @@ def test_gmsh_mesh_with_multi_volume_not_touching(): gmsh_mesh_files = [ "tests/two_disconnected_cubes.msh", ] - for stp_file, mat_tags, gmsh_mesh_file in zip( - stp_files, material_tags, gmsh_mesh_files - ): + for stp_file, mat_tags, gmsh_mesh_file in zip(stp_files, material_tags, gmsh_mesh_files): my_model = CadToDagmc() my_model.add_stp_file(filename=stp_file, material_tags=mat_tags) @@ -238,9 +224,7 @@ def test_gmsh_mesh_with_multi_volume_touching(): "tests/multi_volume_cylinders.msh", "tests/two_connected_cubes.msh", ] - for stp_file, mat_tags, gmsh_mesh_file in zip( - stp_files, material_tags, gmsh_mesh_files - ): + for stp_file, mat_tags, gmsh_mesh_file in zip(stp_files, material_tags, gmsh_mesh_files): my_model = CadToDagmc() my_model.add_stp_file(stp_file, material_tags=mat_tags)