Skip to content

Commit

Permalink
updating pip
Browse files Browse the repository at this point in the history
  • Loading branch information
shimwell committed Dec 17, 2023
1 parent 638f8ea commit 1301ce1
Show file tree
Hide file tree
Showing 14 changed files with 31 additions and 84 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/black.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
pip install black
- name: Run black
run: |
black .
black --line-length 100 .
- uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: "[skip ci] Apply formatting changes"
10 changes: 5 additions & 5 deletions .github/workflows/ci_with_benchmarks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:

- name: install non pypi dependencies for cad creation
shell: bash
run: |s
run: |
wget -O Miniforge3.sh "https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-$(uname)-$(uname -m).sh"
bash Miniforge3.sh -b -p "${HOME}/conda"
source "${HOME}/conda/etc/profile.d/conda.sh"
Expand All @@ -40,10 +40,10 @@ jobs:
mamba install -y -c cadquery -c conda-forge moab gmsh python-gmsh cadquery=master "openmc=0.13.3=dagmc*nompi*"
mamba install -y -c conda-forge "openmc=0.13.3=dagmc*nompi*"
- name: install package
- name: install nuclear data
run: |
pip install .[tests]
pip install cad_to_dagmc openmc_data_downloader
python -m pip install --upgrade pip
python -m pip install cad_to_dagmc openmc_data_downloader
openmc_data_downloader -l ENDFB-7.1-NNDC -i Fe56 Be9
- name: run benchmarks
Expand All @@ -52,5 +52,5 @@ jobs:
run: |
git clone https://github.com/fusion-energy/model_benchmark_zoo.git
cd model_benchmark_zoo
pip install .
python -m pip install .
pytest tests/test_cad_to_dagmc
5 changes: 3 additions & 2 deletions .github/workflows/ci_with_install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ jobs:
- name: install package
run: |
pip install .
python -m pip install --upgrade pip
python -m pip install .
python -c "import cad_to_dagmc"
mamba install -y -c conda-forge "openmc=0.13.3=dagmc*nompi*"
Expand Down Expand Up @@ -111,5 +112,5 @@ jobs:
- name: Run pytest
run: |
pip install .[tests]
python -m pip install .[tests]
pytest tests -v
7 changes: 1 addition & 6 deletions examples/cadquery_compound.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,7 @@
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)


Expand Down
4 changes: 1 addition & 3 deletions examples/cadquery_object_and_stp_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,5 @@

my_model = CadToDagmc()
my_model.add_cadquery_object(object=result, material_tags=["mat1"])
my_model.add_stp_file(
filename="single_cube.stp", material_tags=["mat2"], scale_factor=0.1
)
my_model.add_stp_file(filename="single_cube.stp", material_tags=["mat2"], scale_factor=0.1)
my_model.export_dagmc_h5m_file(max_mesh_size=0.2, min_mesh_size=0.1)
4 changes: 1 addition & 3 deletions examples/cadquery_text.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,4 @@
], # 5 volumes one for each letter
)

my_model.export_dagmc_h5m_file(
filename="cadquery_text.h5m", max_mesh_size=0.2, min_mesh_size=0.1
)
my_model.export_dagmc_h5m_file(filename="cadquery_text.h5m", max_mesh_size=0.2, min_mesh_size=0.1)
7 changes: 1 addition & 6 deletions examples/create_stp_files_for_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 1 addition & 3 deletions examples/single_stp_file_multiple_volumes.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,5 @@

my_model = CadToDagmc()
# the d and c from the word dagmc would be tagged with one material and the agm are tagged with another material
my_model.add_stp_file(
"text_dagmc.stp", material_tags=["mat1", "mat2", "mat2", "mat2", "mat1"]
)
my_model.add_stp_file("text_dagmc.stp", material_tags=["mat1", "mat2", "mat2", "mat2", "mat1"])
my_model.export_dagmc_h5m_file()
30 changes: 8 additions & 22 deletions src/cad_to_dagmc/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ def define_moab_core_and_tags() -> typing.Tuple[core.Core, dict]:

def vertices_to_h5m(
vertices: typing.Union[
typing.Iterable[typing.Tuple[float, float, float]], typing.Iterable["cadquery.occ_impl.geom.Vector"]
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]]],
material_tags: typing.Iterable[str],
Expand All @@ -102,11 +103,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))
Expand Down Expand Up @@ -156,9 +153,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")

Expand Down Expand Up @@ -229,7 +224,6 @@ def mesh_brep(
gmsh.option.setNumber("General.Terminal", 1)
gmsh.model.add("made_with_brep_to_h5m_package")
volumes = gmsh.model.occ.importShapesNativePointer(brep_object)
# gmsh.model.occ.importShapes(brep_object)
gmsh.model.occ.synchronize()

gmsh.option.setNumber("Mesh.Algorithm", mesh_algorithm)
Expand Down Expand Up @@ -296,8 +290,7 @@ def mesh_to_h5m_in_memory_method(
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
Expand Down Expand Up @@ -354,9 +347,7 @@ def merge_surfaces(parts):
if len(parts) == 1:
# merged_solid = cq.Compound(solids)

if isinstance(
parts[0], (cq.occ_impl.shapes.Compound, cq.occ_impl.shapes.Solid)
):
if isinstance(parts[0], (cq.occ_impl.shapes.Compound, cq.occ_impl.shapes.Solid)):
# stp file
return parts[0], parts[0].wrapped
else:
Expand Down Expand Up @@ -460,10 +451,7 @@ def export_dagmc_h5m_file(
for part in self.parts:
assembly.add(part)

(
imprinted_assembly,
imprinted_solids_with_original_id,
) = cq.occ_impl.assembly.imprint(assembly)
imprinted_assembly, imprinted_solids_with_org_id = cq.occ_impl.assembly.imprint(assembly)

gmsh, volumes = mesh_brep(
brep_object=imprinted_assembly.wrapped._address(),
Expand All @@ -473,9 +461,7 @@ def export_dagmc_h5m_file(
)

original_ids = get_ids_from_assembly(assembly)
scrambled_ids = get_ids_from_imprinted_assembly(
imprinted_solids_with_original_id
)
scrambled_ids = get_ids_from_imprinted_assembly(imprinted_solids_with_org_id)

# both id lists should be the same length as each other and the same
# length as the self.material_tags
Expand Down
22 changes: 4 additions & 18 deletions tests/test_file_creation.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,31 +133,17 @@ 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(
object=compound_of_workplanes, material_tags=["mat1", "mat2"]
)
my_model.add_cadquery_object(object=compound_of_workplanes, material_tags=["mat1", "mat2"])
my_model.export_dagmc_h5m_file(
filename="compound_dagmc.h5m", max_mesh_size=0.2, min_mesh_size=0.1
)
Expand Down
8 changes: 2 additions & 6 deletions tests/test_h5m_in_simulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,7 @@ def test_h5m_with_multi_volume_not_touching():
"tests/two_disconnected_cubes.h5m",
]
for mat_tags, h5m_file in zip(material_tags, h5m_files):
transport_particles_on_h5m_geometry(
h5m_filename=h5m_file, material_tags=mat_tags
)
transport_particles_on_h5m_geometry(h5m_filename=h5m_file, material_tags=mat_tags)


def test_h5m_with_multi_volume_touching():
Expand All @@ -136,6 +134,4 @@ def test_h5m_with_multi_volume_touching():
"tests/two_connected_cubes.h5m",
]
for mat_tags, h5m_file in zip(material_tags, h5m_files):
transport_particles_on_h5m_geometry(
h5m_filename=h5m_file, material_tags=mat_tags
)
transport_particles_on_h5m_geometry(h5m_filename=h5m_file, material_tags=mat_tags)
4 changes: 1 addition & 3 deletions tests/test_loading_from_file_vs_shape_object.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@

def test_order_material_ids_by_brep_order():
# two entries, reverse order
new_order = cad_to_dagmc.order_material_ids_by_brep_order(
["1", "2"], ["2", "1"], ["m1", "m2"]
)
new_order = cad_to_dagmc.order_material_ids_by_brep_order(["1", "2"], ["2", "1"], ["m1", "m2"])
assert new_order == ["m2", "m1"]

# three entries, partly duplicate materials
Expand Down
4 changes: 1 addition & 3 deletions tests/test_match.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@ def get_ids_from_imprinted_assembly(solid_id_dict):
return ids


imprinted_assembly, imprinted_solids_with_original_id = cq.occ_impl.assembly.imprint(
assembly
)
imprinted_assembly, imprinted_solids_with_original_id = cq.occ_impl.assembly.imprint(assembly)

original_ids = get_ids_from_assembly(assembly)
scrambled_ids = get_ids_from_imprinted_assembly(imprinted_solids_with_original_id)
Expand Down
4 changes: 1 addition & 3 deletions tests/test_package.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,7 @@ def get_volumes_and_materials_from_h5m(filename: str) -> dict:
return vol_mat


def transport_particles_on_h5m_geometry(
h5m_filename, material_tags, cross_sections_xml=None
):
def transport_particles_on_h5m_geometry(h5m_filename, material_tags, cross_sections_xml=None):
"""A function for testing the geometry file with particle transport in DAGMC OpenMC"""

materials = openmc.Materials()
Expand Down

0 comments on commit 1301ce1

Please sign in to comment.