Skip to content

Commit

Permalink
Alphabetizing Flags.toString results (#1912)
Browse files Browse the repository at this point in the history
  • Loading branch information
john-science authored Oct 1, 2024
1 parent 3b1a789 commit 356750c
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 9 deletions.
3 changes: 2 additions & 1 deletion armi/reactor/flags.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,8 @@ def _toString(cls, typeSpec):
-----
This converts a flag from ``Flags.A|B`` to ``'A B'``
"""
return str(typeSpec).split("{}.".format(cls.__name__))[1].replace("|", " ")
strings = str(typeSpec).split("{}.".format(cls.__name__))[1]
return " ".join(sorted(strings.split("|")))


class Flags(Flag):
Expand Down
8 changes: 8 additions & 0 deletions armi/reactor/tests/test_flags.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,14 @@ def test_flagsToAndFromString(self):
self.assertEqual(flags.Flags.toString(f), "FUEL")
self.assertEqual(f, flags.Flags.fromString("FUEL"))

def test_toStringAlphabetical(self):
"""Ensure that, for multiple flags, toString() returns them in alphabetical order."""
flagz = flags.Flags.AXIAL | flags.Flags.LOWER
self.assertEqual(flags.Flags.toString(flagz), "AXIAL LOWER")

flagz = flags.Flags.LOWER | flags.Flags.AXIAL
self.assertEqual(flags.Flags.toString(flagz), "AXIAL LOWER")

def test_fromStringStrict(self):
self._help_fromString(flags.Flags.fromString)
with self.assertRaises(flags.InvalidFlagsError):
Expand Down
13 changes: 5 additions & 8 deletions doc/release/0.4.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,15 @@ New Features
#. Allow merging a component with zero area into another component (`PR#1858 <https://github.com/terrapower/armi/pull/1858>`_)
#. Provide utilities for determining location of a rotated object in a hexagonal lattice (``getIndexOfRotatedCell``). (`PR#1846 <https://github.com/terrapower/armi/1846`)
#. Allow merging a component with zero area into another component. (`PR#1858 <https://github.com/terrapower/armi/pull/1858>`_)
#. Provide ``Parameter.hasCategory`` for quickly checking if a parameter is defined with a given category.
(`PR#1899 <https://github.com/terrapower/armi/pull/1899>`_)
#. Provide ``ParameterCollection.where`` for efficient iteration over parameters who's definition.
matches a given condition. (`PR#1899 <https://github.com/terrapower/armi/pull/1899>`_)
#. Plugins can provide the ``getAxialExpansionChanger`` hook to customize axial expansion.
(`PR#1870 <https://github.com/terrapower/armi/pull/1870`_)
#. Provide ``Parameter.hasCategory`` for quickly checking if a parameter is defined with a given category. (`PR#1899 <https://github.com/terrapower/armi/pull/1899>`_)
#. Provide ``ParameterCollection.where`` for efficient iteration over parameters who's definition matches a given condition. (`PR#1899 <https://github.com/terrapower/armi/pull/1899>`_)
#. Plugins can provide the ``getAxialExpansionChanger`` hook to customize axial expansion. (`PR#1870 <https://github.com/terrapower/armi/pull/1870`_)
#. TBD

API Changes
-----------
#. Removing flags ``CORE`` and ``REACTOR``. (`PR#1835 <https://github.com/terrapower/armi/pull/1835>`_)
#. Alphabetizing ``Flags.toString()`` results. (`PR#1912 <https://github.com/terrapower/armi/pull/1912>`_)
#. Moving ``settingsValidation`` from ``operators`` to ``settings``. (`PR#1895 <https://github.com/terrapower/armi/pull/1895>`_)
#. Removing deprecated method ``prepSearch``. (`PR#1845 <https://github.com/terrapower/armi/pull/1845>`_)
#. Removing unused function ``SkippingXsGen_BuChangedLessThanTolerance``. (`PR#1845 <https://github.com/terrapower/armi/pull/1845>`_)
Expand All @@ -42,8 +40,7 @@ Bug Fixes
#. Changed data type of ``thKernel`` setting from ``bool`` to ``str`` in ``ThermalHydraulicsPlugin``. (`PR#1855 <https://github.com/terrapower/armi/pull/1855>`_)
#. Rotate hexagonal assembly patches correctly on facemap plots. (`PR#1883 <https://github.com/terrapower/armi/pull/1883>`_)
#. Update height of fluid components after axial expansion (`PR#1828 <https://github.com/terrapower/armi/pull/1828>`_)
#. Material theoretical density is serialized to and read from database.
(`PR#1852 <https://github.com/terrapower/armi/pull/1852>`_)
#. Material theoretical density is serialized to and read from database. (`PR#1852 <https://github.com/terrapower/armi/pull/1852>`_)
#. TBD

Quality Work
Expand Down

0 comments on commit 356750c

Please sign in to comment.