Repository: CORE-GATECH-GROUP/serpent-tools
Pull request #2 (2017-09-18 18:44:06)

Quick: DepletedMaterial returns time vector if not given as input


Patch:
diff --git a/serpentTools/__init__.py b/serpentTools/__init__.py
index 6631e0a..8af8d0f 100644
--- a/serpentTools/__init__.py
+++ b/serpentTools/__init__.py
@@ -1,7 +1,7 @@
 from serpentTools import settings
 from serpentTools import parsers
 
-__version__ = '0.1.0'
+__version__ = '0.1.1'
 
 # List TODOS/feature requests here for now
 # Messages/Errors
@@ -11,9 +11,6 @@ __version__ = '0.1.0'
 # Compatability
 # TODO: Python 2 support
 # TODO: Test compatability with earlier numpy releases
-# Pythonicness/cleanliness
-# TODO: Better rc importing and usage
-# TODO: Remove need to specify all settings as a default setting object
 # Usage/scripting
 # TODO: Update rc with dictionary
 # TODO: Update rc with yaml file into dictionary
diff --git a/serpentTools/objects/__init__.py b/serpentTools/objects/__init__.py
index 68d7181..42ee6c0 100644
--- a/serpentTools/objects/__init__.py
+++ b/serpentTools/objects/__init__.py
@@ -137,9 +137,9 @@ class DepletedMaterial(_SupportingObject):
         Returns
         -------
         numpy.array
-            Vector of time points
+            Array of values.
         numpy.array
-            Array of values
+            Vector of time points only if ``timePoints`` is ``None``
 
         Raises
         ------
@@ -147,6 +147,7 @@ class DepletedMaterial(_SupportingObject):
             If the names of the isotopes have not been obtained and specific
             isotopes have been requested
         """
+        returnX = timePoints is None
         if names and 'names' not in self._container.metadata:
             raise AttributeError('Parser {} has not stored the isotope names.'
                                  .format(self._container))
@@ -159,7 +160,9 @@ class DepletedMaterial(_SupportingObject):
         for isoID, rowId in enumerate(rowIndices):
             yVals[isoID, :] = (allY[rowId][colIndices] if colIndices
                                else allY[rowId][:])
-        return xVals, yVals
+        if returnX:
+            return yVals, xVals
+        return yVals
 
     def _getXSlice(self, xUnits, timePoints):
         allX = self[xUnits]


Test patch:
diff --git a/serpentTools/tests/test_depletion.py b/serpentTools/tests/test_depletion.py
index 17d2c6d..0574305 100644
--- a/serpentTools/tests/test_depletion.py
+++ b/serpentTools/tests/test_depletion.py
@@ -23,7 +23,7 @@ class _DepletionTestHelper(unittest.TestCase):
         cls.reader.read()
 
 
-class Test_Depletion(_DepletionTestHelper):
+class DepletionTester(_DepletionTestHelper):
     """Class that tests the functionality of the depletion reader."""
 
     def test_metadata(self):
@@ -146,10 +146,16 @@ class DepletedMaterialTester(_DepletionTestHelper):
             [0.00000E+00, 2.90880E-14, 5.57897E-14, 2.75249E-13, 5.46031E-13,
              1.35027E-12, 2.64702E-12],
         ], float)
-        _days, actual = self.material.getXY('days', 'adens', names=names,
-                                            timePoints=self.requestedDays)
+        actual = self.material.getXY('days', 'adens', names=names,
+                                     timePoints=self.requestedDays)
         numpy.testing.assert_allclose(actual, expected, rtol=1E-4)
 
+    def test_getXY_adensAndTime(self):
+        """Verify correct atomic density and time slice are returned."""
+        actualAdens, actualDays = self.material.getXY('days', 'adens',
+                                                      names=['Xe135'])
+        numpy.testing.assert_equal(actualDays, self.reader.metadata['days'])
+
 
 if __name__ == '__main__':
     unittest.main()