Skip to content

Commit

Permalink
Making IDs on sets mutable
Browse files Browse the repository at this point in the history
  • Loading branch information
pshriwise committed Jan 16, 2024
1 parent 50022cb commit b580dbd
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
8 changes: 7 additions & 1 deletion dagmc/dagnav.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,12 @@ def id(self):
"""
return self.model.mb.tag_get_data(self.model.id_tag, self.handle, flat=True)[0]

@id.setter
def id(self, i):
"""Set the DAGMC set's ID.
"""
self.model.mb.tag_set_data(self.model.id_tag, self.handle, i)

@property
def geom_dimension(self):
"""Return the DAGMC set's geometry dimension.
Expand Down Expand Up @@ -334,4 +340,4 @@ def create(cls, model, name):
mb.tag_set_data(model.name_tag, group_handle, name)
mb.tag_set_data(model.category_tag, group_handle, 'Group')
mb.tag_set_data(model.geom_dimension_tag, group_handle, 4)
return cls(model, group_handle)
return cls(model, group_handle)
8 changes: 7 additions & 1 deletion test/test_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,13 @@ def test_group_merge(request):
new_group = dagmc.Group.create(model, 'mat:fuel')
assert orig_group != new_group


# check that we can update a set ID
assert new_group.id == -1
new_group.id = 100
assert new_group.id == 100


# merge the new group into the existing group
orig_group.merge(new_group)
assert orig_group == new_group
Expand All @@ -102,7 +109,6 @@ def test_group_merge(request):
# volume set w/ ID 3 now
fuel_group = groups['mat:fuel']
assert 3 in fuel_group.get_volumes()
assert len(fuel_group.get_volumes()) == orig_group_size + 1


def test_compressed_coords(request, capfd):
Expand Down

0 comments on commit b580dbd

Please sign in to comment.