Skip to content

Commit

Permalink
Merge pull request #7 from svalinn/model_write
Browse files Browse the repository at this point in the history
Adding option to write file from the `DAGModel` class.
  • Loading branch information
gonuke authored Feb 12, 2024
2 parents 79dcc62 + b91d736 commit a400ca6
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
9 changes: 9 additions & 0 deletions dagmc/dagnav.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,15 @@ def geom_dimension_tag(self):
create_if_missing=True,
)

def write_file(self, filename):
"""Write the model to a file.
Parameters
----------
filename : str
The file to write to.
"""
self.mb.write_file(filename)

class DAGSet:
"""
Expand Down
9 changes: 9 additions & 0 deletions test/test_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@ def test_eq(request):

assert model1_v0 != model2_v0


def test_delete(fuel_pin_model):
model = dagmc.DAGModel(fuel_pin_model)

Expand All @@ -270,3 +271,11 @@ def test_delete(fuel_pin_model):
assert 'mat:fuel' not in model.groups


def test_write(request, tmpdir):
test_file = str(request.path.parent / 'fuel_pin.h5m')
model = dagmc.DAGModel(test_file)
model.volumes[1].id = 12345
model.write_file('fuel_pin_copy.h5m')

model = dagmc.DAGModel('fuel_pin_copy.h5m')
assert 12345 in model.volumes

0 comments on commit a400ca6

Please sign in to comment.