Skip to content

Commit

Permalink
Merge pull request #334 from drewejohnson/0.8.0-deprecations
Browse files Browse the repository at this point in the history
API Introduce potentially breaking changes for 0.8.0 

- Serpent 2.1.31 is the default version of the serpentVersion setting. 
  This really only affects the results reader. Other readers are left alone. 
  This version was supported in an exploratory stance in version 0.7.0 [26b2e0c]
- Setting expectGcu has been removed. This setting was deprecated with PR #324
  and any attempt to alter this setting notified the user of this deprecation [72b3481]
- Remove the workaround that allowed integer universe names when reading from
  coefficient files. This was brought up in #318 / #321 with a1e6fa2 and now is removed.
  • Loading branch information
drewejohnson committed Sep 8, 2019
2 parents b9f3b02 + f92df23 commit 88b5707
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 79 deletions.
6 changes: 6 additions & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,18 @@ Next

* Better handling of discontinuity factors
* |HomogUniv| objects no longer automatically convert data to arrays
* Serpent 2.1.31 is the default version for :ref:`serpentVersion` setting

Incompatible API Changes
------------------------

* Values are stored in array form on |HomogUniv| when it makes sense.
For example, values like ``infKinf`` are stored as scalars.
* Setting ``expectGcu`` has been removed as :pull:`324` fixed how files without
group constants are handled.
* Keys to |BranchedUniv| objects stored in
:attr:`serpentTools.xs.BranchCollector.universes` are stored as strings,
rather than integers, e.g. ``0`` is replaced with ``"0"`` - :pull:`321`

.. _v0.7.1
Expand Down
2 changes: 1 addition & 1 deletion docs/defaultSettings.rst
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ If True, no checks are performed prior to preparing data. Set this to be True on
Version of SERPENT
::

Default: 2.1.29
Default: 2.1.31
Type: str
Options: [2.1.29, 2.1.30, 2.1.31]

Expand Down
37 changes: 1 addition & 36 deletions serpentTools/objects/containers.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
"""
from itertools import product
from warnings import warn
from numbers import Real

from six import iteritems, PY2
from matplotlib import pyplot
Expand Down Expand Up @@ -40,11 +38,6 @@
error,
)

if PY2:
from collections import Iterable
else:
from collections.abc import Iterable

SCATTER_MATS = set()
SCATTER_ORDERS = 8

Expand Down Expand Up @@ -612,33 +605,6 @@ def compareGCData(self, other, sigma):
compareGCData.__doc__ = __docCompare.format(qty='gc')


# remove for versions >= 0.8.0

class _BranchContainerUnivDict(dict):
"""
Workaround for supporting integer and string universe ids
Keys are of the form ``univID, index, burnup``
"""

def __getitem__(self, key):
if not isinstance(key, Iterable):
raise KeyError(key)
if isinstance(key[0], Real) and key not in self:
warn("Universe ids are stored as unconverted strings, not int. "
"Support for previous integer-access will be removed in "
"future versions.",
FutureWarning)
key = (str(key[0]), ) + key[1:]
return dict.__getitem__(self, key)

def get(self, key, default=None):
try:
return self[key]
except KeyError:
return default


class BranchContainer(BaseObject):
"""
Class that stores data for a single branch.
Expand Down Expand Up @@ -677,8 +643,7 @@ def __init__(self, filePath, branchID, branchNames, stateData):
self.filePath = filePath
self.branchID = branchID
self.stateData = stateData
# Revert to dict for version >= 0.8.0
self.universes = _BranchContainerUnivDict()
self.universes = {}
self.branchNames = branchNames
self.__orderedUniverses = None
self.__keys = set()
Expand Down
1 change: 1 addition & 0 deletions serpentTools/parsers/results.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
},
}
MapStrVersions['2.1.30'] = MapStrVersions['2.1.29']
MapStrVersions['2.1.31'] = MapStrVersions['2.1.29']
"""
Assigns search strings for different Serpent versions
"""
Expand Down
7 changes: 5 additions & 2 deletions serpentTools/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"""

_DEPRECATED = {'results.expectGcu'}
_DEPRECATED = set()

SETTING_OPTIONS_FMTR = "Options: [{}]"
defaultSettings = {
Expand Down Expand Up @@ -106,8 +106,11 @@
'type': bool
},
'serpentVersion': {
'default': '2.1.30',
'default': '2.1.31',
'options': ['2.1.29', '2.1.30', '2.1.31'],
# When adding new version of Serpent, add / update
# MapStrVersions with variables that indicate the start of specific
# data blocks / time parameters like burnup
'description': 'Version of SERPENT',
'type': str
},
Expand Down
33 changes: 1 addition & 32 deletions serpentTools/xs.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

from itertools import product
from warnings import warn
from numbers import Real

from six import iteritems
from six.moves import range
Expand All @@ -20,35 +19,6 @@
]


# remove for versions >= 0.8.0


class IntToStringDict(dict):
"""Dictionary that allows accessing string keys with Reals
Used to mitigate API changes in how universe keys are stored
in BranchingReader and BranchCollector objects.
"""

def __getitem__(self, key):
if key in self:
return dict.__getitem__(self, key)
if isinstance(key, Real) and float(key) in self:
warn("Universes will be stored as unconverted strings in future "
"versions", FutureWarning)
return dict.__getitem__(self, str(key))
raise KeyError(key)

def get(self, key, default=None):
if key in self:
return dict.__getitem__(self, key)
if isinstance(key, Real) and float(key) in self:
warn("Universes will be stored as unconverted strings in future "
"versions", FutureWarning)
return dict.__getitem__(self, str(key))
return dict.get(self, key, default)


class BranchedUniv(object):
"""
Class for storing cross sections for a single universe across branches
Expand Down Expand Up @@ -255,8 +225,7 @@ def __init__(self, source):
self.filePath = reader.filePath
self._branches = reader.branches
self.xsTables = {}
# Revert do dict for version >= 0.8.0
self.universes = IntToStringDict()
self.universes = {}
self._perturbations = None
self._states = None
self._axis = None
Expand Down
2 changes: 0 additions & 2 deletions tests/test_ResultsReader.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ def test_emptyFile_noGcu(self):
for _line in range(5):
badObj.write(str(_line))
badReader = ResultsReader(badFile)
badReader.settings['expectGcu'] = False
with self.assertRaises(SerpentToolsException):
badReader.read()
remove(badFile)
Expand Down Expand Up @@ -608,7 +607,6 @@ def setUp(self):
'diffusion', 'eig', 'burnup-coeff']
rc['xs.getInfXS'] = True # only store inf cross sections
rc['xs.getB1XS'] = False
rc['results.expectGcu'] = False
self.reader = ResultsReader(self.file)
self.reader.read()

Expand Down
6 changes: 0 additions & 6 deletions tests/test_branching.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,6 @@ def setUpClass(cls):
cls.refBranch = cls.reader.branches[cls.refBranchID]
cls.refUniv = cls.refBranch.universes[cls.refUnivKey]

def test_universeIDWorkaround(self):
"""Test that, for now, integer universe ids work"""
# Remove this test for versions >= 0.8.0
key = (int(self.refUnivKey[0]), ) + self.refUnivKey[1:]
self.assertIs(self.refUniv, self.refBranch.universes[key])

def test_loadedUniv(self):
"""Verify the reference universe has the correct data loaded"""
assortedExpected = {
Expand Down

0 comments on commit 88b5707

Please sign in to comment.