Skip to content

Commit

Permalink
Address comments by @smharper on openmc-dev#892.
Browse files Browse the repository at this point in the history
  • Loading branch information
paulromano committed Jun 15, 2017
1 parent 3a8205c commit 002c765
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 8 deletions.
13 changes: 9 additions & 4 deletions openmc/mixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ def __ne__(self, other):
return not self.__eq__(other)


class IDWarning(UserWarning):
pass


class IDManagerMixin(object):
"""A Class which automatically manages unique IDs.
Expand Down Expand Up @@ -52,8 +56,9 @@ def id(self, uid):
cv.check_type('{} ID'.format(name), uid, Integral)
cv.check_greater_than('{} ID'.format(name), uid, 0, equality=True)
if uid in cls.used_ids:
warn('Another {} instance already exists with id={}.'.format(
name, uid))
msg = 'Another {} instance already exists with id={}.'.format(
name, uid)
warn(msg, IDWarning)
else:
cls.used_ids.add(uid)
self._id = uid
Expand All @@ -74,8 +79,8 @@ def reserve_ids(ids, cls=None):
ids : iterable of int
IDs to reserve
cls : type or None
Class for which IDs should be reserved. If None, all classes that have
auto-generated IDs will be used.
Class for which IDs should be reserved (e.g., :class:`openmc.Cell`). If
None, all classes that have auto-generated IDs will be used.
"""
if cls is None:
Expand Down
2 changes: 1 addition & 1 deletion openmc/statepoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ def tallies(self):

# Ignore warnings about duplicate IDs
with warnings.catch_warnings():
warnings.simplefilter('ignore', UserWarning)
warnings.simplefilter('ignore', openmc.IDWarning)

# Iterate over all tallies
for tally_id in tally_ids:
Expand Down
2 changes: 1 addition & 1 deletion openmc/summary.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def __init__(self, filename):

self._read_nuclides()
with warnings.catch_warnings():
warnings.simplefilter("ignore", UserWarning)
warnings.simplefilter("ignore", openmc.IDWarning)
self._read_geometry()

@property
Expand Down
2 changes: 1 addition & 1 deletion openmc/volume.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ def from_hdf5(cls, filename):
# Instantiate some throw-away domains that are used by the constructor
# to assign IDs
with warnings.catch_warnings():
warnings.simplefilter('ignore', UserWarning)
warnings.simplefilter('ignore', openmc.IDWarning)
if domain_type == 'cell':
domains = [openmc.Cell(uid) for uid in ids]
elif domain_type == 'material':
Expand Down
1 change: 0 additions & 1 deletion src/physics.F90
Original file line number Diff line number Diff line change
Expand Up @@ -818,7 +818,6 @@ subroutine sample_target_velocity(nuc, v_target, E, uvw, v_neut, wgt, xs_eff, kT
real(8) :: xs_low ! 0K xs at lowest practical relative energy
real(8) :: xs_up ! 0K xs at highest practical relative energy
real(8) :: m ! slope for interpolation
real(8) :: xi ! pseudorandom number on [0,1)
real(8) :: R ! rejection criterion for DBRC / target speed
real(8) :: cdf_low ! xs cdf at lowest practical relative energy
real(8) :: cdf_up ! xs cdf at highest practical relative energy
Expand Down

0 comments on commit 002c765

Please sign in to comment.