Skip to content

Commit

Permalink
Adding even more impl/test crumbs (#1473)
Browse files Browse the repository at this point in the history
Added test crumbs for:

- ncases
- materials

And added impl and test crumbs for:

- database3
- snapshots
- uniform mesh converter
-axial expansion changer
  • Loading branch information
john-science authored Nov 14, 2023
1 parent 6603c1d commit 5b3555c
Show file tree
Hide file tree
Showing 18 changed files with 293 additions and 16 deletions.
4 changes: 4 additions & 0 deletions armi/bookkeeping/db/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,10 @@ def _getH5File(db):
All this being said, we are probably violating this already with genAuxiliaryData,
but we have to start somewhere.
.. impl:: The ARMI output file has a language-agnostic format.
:id: I_ARMI_DB_H5
:implements: R_ARMI_DB_H5
"""
if isinstance(db, Database3):
return db.h5db
Expand Down
2 changes: 0 additions & 2 deletions armi/bookkeeping/db/database3.py
Original file line number Diff line number Diff line change
Expand Up @@ -1458,7 +1458,6 @@ def packSpecialData(
``None`` with a magical value that shouldn't be encountered in realistic
scenarios.
Parameters
----------
data
Expand Down Expand Up @@ -1610,7 +1609,6 @@ def unpackSpecialData(data: numpy.ndarray, attrs, paramName: str) -> numpy.ndarr
An ndarray containing the closest possible representation of the data that was
originally written to the database.
See Also
--------
packSpecialData
Expand Down
4 changes: 4 additions & 0 deletions armi/bookkeeping/db/databaseInterface.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,10 @@ def prepRestartRun(self):
`startCycle` and `startNode`, having loaded the state from all cycles prior
to that in the requested database.
.. impl:: Runs at a particular timenode can be re-instantiated for a snapshot.
:id: I_ARMI_SNAPSHOT_RESTART
:implements: R_ARMI_SNAPSHOT_RESTART
Notes
-----
Mixing the use of simple vs detailed cycles settings is allowed, provided
Expand Down
11 changes: 11 additions & 0 deletions armi/bookkeeping/db/tests/test_database3.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,13 @@ def test_writeToDB(self):
)

def test_getH5File(self):
"""
Get the h5 file for the database, because that file format is language-agnostic.
.. test:: Show the database is H5-formatted.
:id: T_ARMI_DB_H5
:tests: R_ARMI_DB_H5
"""
with self.assertRaises(TypeError):
_getH5File(None)

Expand Down Expand Up @@ -185,6 +192,10 @@ def test_prepRestartRun(self):
above. In that cs, `reloadDBName` is set to 'reloadingDB.h5', `startCycle` = 1,
and `startNode` = 2. The nonexistent 'reloadingDB.h5' must first be
created here for this test.
.. test:: Runs can be restarted from a snapshot.
:id: T_ARMI_SNAPSHOT_RESTART
:tests: R_ARMI_SNAPSHOT_RESTART
"""
# first successfully call to prepRestartRun
o, r = loadTestReactor(
Expand Down
8 changes: 7 additions & 1 deletion armi/bookkeeping/snapshotInterface.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,13 @@ def describeInterfaces(cs):


class SnapshotInterface(interfaces.Interface):
"""Snapshot managerial interface."""
"""
Snapshot managerial interface.
.. impl:: Save extra data to be saved from a run, at specified time nodes.
:id: I_ARMI_SNAPSHOT0
:implements: R_ARMI_SNAPSHOT
"""

name = "snapshot"

Expand Down
14 changes: 14 additions & 0 deletions armi/bookkeeping/tests/test_snapshot.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,13 @@ def test_interactCoupled(self, mockSnapshotRequest):
self.assertTrue(mockSnapshotRequest.called)

def test_activeateDefaultSnapshots_30cycles2BurnSteps(self):
"""
Test snapshots for 30 cycles and 2 burnsteps, checking the dumpSnapshot setting.
.. test:: Allow extra data to be saved from a run, at specified time nodes.
:id: T_ARMI_SNAPSHOT0
:tests: R_ARMI_SNAPSHOT
"""
self.assertEqual([], self.cs["dumpSnapshot"])

newSettings = {}
Expand All @@ -72,6 +79,13 @@ def test_activeateDefaultSnapshots_30cycles2BurnSteps(self):
self.assertEqual(["000000", "014000", "029002"], self.si.cs["dumpSnapshot"])

def test_activeateDefaultSnapshots_17cycles5BurnSteps(self):
"""
Test snapshots for 17 cycles and 5 burnsteps, checking the dumpSnapshot setting.
.. test:: Allow extra data to be saved from a run, at specified time nodes.
:id: T_ARMI_SNAPSHOT1
:tests: R_ARMI_SNAPSHOT
"""
self.assertEqual([], self.cs["dumpSnapshot"])

newSettings = {}
Expand Down
8 changes: 8 additions & 0 deletions armi/cases/case.py
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,10 @@ def run(self):
It also activates supervisory things like code coverage checking, profiling,
or tracing, if requested by users during debugging.
.. impl:: The case class allows for a generic ARMI simulation.
:id: I_ARMI_CASE
:implements: R_ARMI_CASE
Notes
-----
Room for improvement: The coverage, profiling, etc. stuff can probably be moved
Expand Down Expand Up @@ -556,6 +560,10 @@ def checkInputs(self):
"""
Checks ARMI inputs for consistency.
.. impl:: Perform validity checks on case inputs.
:id: I_ARMI_CASE_CHECK
:implements: R_ARMI_CASE_CHECK
Returns
-------
bool
Expand Down
4 changes: 4 additions & 0 deletions armi/cases/inputModifiers/inputModifiers.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ class InputModifier:
Some subclasses are provided, but you are expected to make your own design-specific
modifiers in most cases.
.. impl:: A generic tool to modify user inputs on multiple cases.
:id: I_ARMI_CASE_MOD1
:implements: R_ARMI_CASE_MOD
"""

FAIL_IF_AFTER = ()
Expand Down
4 changes: 4 additions & 0 deletions armi/cases/suiteBuilder.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ class SuiteBuilder:
"""
Class for constructing a CaseSuite from combinations of modifications on base inputs.
.. impl:: A generic tool to modify user inputs on multiple cases.
:id: I_ARMI_CASE_MOD0
:implements: R_ARMI_CASE_MOD
Attributes
----------
baseCase : armi.cases.case.Case
Expand Down
18 changes: 17 additions & 1 deletion armi/cases/tests/test_cases.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,12 @@ def test_clone(self):


class TestCaseSuiteDependencies(unittest.TestCase):
"""CaseSuite tests."""
"""CaseSuite tests.
.. test:: Dependence allows for one case to start after the completion of another.
:id: T_ARMI_CASE_SUITE0
:tests: R_ARMI_CASE_SUITE
"""

def setUp(self):
self.suite = cases.CaseSuite(settings.Settings())
Expand All @@ -284,6 +289,17 @@ def test_clone(self):
with self.assertRaises(RuntimeError):
_clone = self.suite.clone("test_clone")

def test_checkInputs(self):
"""
Test the checkInputs() method on a couple of cases.
.. test:: Test the checkInputs method.
:id: T_ARMI_CASE_CHECK
:tests: R_ARMI_CASE_CHECK
"""
self.c1.checkInputs()
self.c2.checkInputs()

def test_dependenciesWithObscurePaths(self):
"""
Test directory dependence.
Expand Down
8 changes: 7 additions & 1 deletion armi/cases/tests/test_suiteBuilder.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,13 @@ def __call__(self, cs, bp, geom):


class TestLatinHyperCubeSuiteBuilder(unittest.TestCase):
"""Class to test LatinHyperCubeSuiteBuilder."""
"""
Class to test LatinHyperCubeSuiteBuilder.
.. test:: A generic mechanism to allow users to modify user inputs in cases.
:id: T_ARMI_CASE_MOD0
:tests: R_ARMI_CASE_MOD
"""

def test_initialize(self):
builder = LatinHyperCubeSuiteBuilder(case, size=20)
Expand Down
7 changes: 6 additions & 1 deletion armi/materials/tests/test_air.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,12 @@


class Test_Air(unittest.TestCase):
"""unit tests for air materials."""
"""unit tests for air materials.
.. test:: There is a base class for fluid materials.
:id: T_ARMI_MAT_FLUID1
:tests: R_ARMI_MAT_FLUID
"""

def test_pseudoDensity(self):
"""
Expand Down
Loading

0 comments on commit 5b3555c

Please sign in to comment.