Skip to content

Commit

Permalink
fix none in id thanks to new test
Browse files Browse the repository at this point in the history
  • Loading branch information
gonuke committed Apr 8, 2024
1 parent 7e9b13f commit ecdbccf
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
6 changes: 3 additions & 3 deletions dagmc/dagnav.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,9 +222,9 @@ def id(self, i: int):
i = max(self.model.used_ids[type(self)], default=0) + 1
elif i in self.model.used_ids[type(self)]:
raise ValueError(f'{self.category} ID {i} is already in use in this model.')
else:
self.model.used_ids[type(self)].discard(self.id)
self.model.used_ids[type(self)].add(i)

self.model.used_ids[type(self)].discard(self.id)
self.model.used_ids[type(self)].add(i)

self._tag_set_data(self.model.id_tag, i)

Expand Down
9 changes: 9 additions & 0 deletions test/test_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,13 @@ def test_id_safety(request):
s1.id = safe_surf_id
assert s1.id == safe_surf_id

s2 = model.surfaces_by_id[2]
s2.id = None
assert s2.id == safe_surf_id + 1

s2.id = 2
assert s2.id == 2

g1 = model.groups_by_name['mat:fuel']

used_grp_id = 2
Expand Down Expand Up @@ -229,6 +236,8 @@ def test_coords(request, capfd):


def test_to_vtk(tmpdir_factory, request):
pass

test_file = str(request.path.parent / 'fuel_pin.h5m')
groups = dagmc.DAGModel(test_file).groups_by_name

Expand Down

0 comments on commit ecdbccf

Please sign in to comment.