From 002c7651c2cf0049c9b6f185535b29f122b62f7d Mon Sep 17 00:00:00 2001 From: Paul Romano Date: Thu, 15 Jun 2017 14:38:25 -0500 Subject: [PATCH] Address comments by @smharper on #892. --- openmc/mixin.py | 13 +++++++++---- openmc/statepoint.py | 2 +- openmc/summary.py | 2 +- openmc/volume.py | 2 +- src/physics.F90 | 1 - 5 files changed, 12 insertions(+), 8 deletions(-) diff --git a/openmc/mixin.py b/openmc/mixin.py index 89b8df2730..d724fc32a0 100644 --- a/openmc/mixin.py +++ b/openmc/mixin.py @@ -25,6 +25,10 @@ class EqualityMixin(object): return not self.__eq__(other) +class IDWarning(UserWarning): + pass + + class IDManagerMixin(object): """A Class which automatically manages unique IDs. @@ -52,8 +56,9 @@ class IDManagerMixin(object): 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 @@ -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: diff --git a/openmc/statepoint.py b/openmc/statepoint.py index 7255a7ba4b..474b03033a 100644 --- a/openmc/statepoint.py +++ b/openmc/statepoint.py @@ -358,7 +358,7 @@ class StatePoint(object): # 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: diff --git a/openmc/summary.py b/openmc/summary.py index 30ba77f985..34743757b4 100644 --- a/openmc/summary.py +++ b/openmc/summary.py @@ -52,7 +52,7 @@ class Summary(object): self._read_nuclides() with warnings.catch_warnings(): - warnings.simplefilter("ignore", UserWarning) + warnings.simplefilter("ignore", openmc.IDWarning) self._read_geometry() @property diff --git a/openmc/volume.py b/openmc/volume.py index 721dcf2485..cccb3c6a27 100644 --- a/openmc/volume.py +++ b/openmc/volume.py @@ -223,7 +223,7 @@ class VolumeCalculation(object): # 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': diff --git a/src/physics.F90 b/src/physics.F90 index 920835d8e7..9482772ef1 100644 --- a/src/physics.F90 +++ b/src/physics.F90 @@ -818,7 +818,6 @@ contains 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