From 3c22a405fee0ebed2600a5ccacb1bd8f73939e7e Mon Sep 17 00:00:00 2001 From: shimwell Date: Tue, 2 Aug 2022 20:29:19 +0100 Subject: [PATCH] added doc strings for time_units --- openmc/deplete/results.py | 23 ++++++++++++++++---- tests/unit_tests/test_deplete_resultslist.py | 2 +- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/openmc/deplete/results.py b/openmc/deplete/results.py index 6feac89b63..017c9c6683 100644 --- a/openmc/deplete/results.py +++ b/openmc/deplete/results.py @@ -16,6 +16,17 @@ __all__ = ["Results", "ResultsList"] def _get_time_as(seconds, units): + """Converts the time in seconds to time in different units + + Parameters + ---------- + seconds : float + The time to convert expressed in seconds + units : {"s", "min", "h", "d", "a"} + The units to convert time into. Available options are seconds ``"s"``, + minutes ``"min"``, hours ``"hours"`` days ``"d"``, years ``"a"`` + + """ if units == "a": return seconds / (60 * 60 * 24 * 365.25) # 365.25 due to the leap year if units == "d": @@ -99,7 +110,8 @@ class Results(list): .. versionadded:: 0.12 time_units : {"s", "min", "h", "d", "a"}, optional Units for the returned time array. Default is ``"s"`` to - return the value in seconds. + return the value in seconds. Other options are minutes ``"min"``, + hours ``"hours"``, days ``"d"``, years ``"a"`` .. versionadded:: 0.12 @@ -193,7 +205,8 @@ class Results(list): Parameters ---------- time_units : {"s", "d", "min", "h", "a"}, optional - Desired units for the times array + Desired units for the times array. Options are seconds ``"s"`` + minutes ``"min"``, hours ``"hours"``, days ``"d"``, years ``"a"`` Returns ------- @@ -261,7 +274,8 @@ class Results(list): ---------- time_units : {"s", "d", "min", "h", "a"}, optional Return the vector in these units. Default is to - convert to days + convert to days ``"d"``. Other options are seconds ``"s"``, minutes + ``"min"``, hours ``"hours"``, years ``"a"`` Returns ------- @@ -299,7 +313,8 @@ class Results(list): time : float Desired point in time time_units : {"s", "d", "min", "h", "a"}, optional - Units on ``time``. Default: days + Units on ``time``. Default: days ``"d"``. Other options are seconds + ``"s"``, minutes ``"min"``, hours ``"hours"`` and years ``"a"`` atol : float, optional Absolute tolerance (in ``time_units``) if ``time`` is not found. diff --git a/tests/unit_tests/test_deplete_resultslist.py b/tests/unit_tests/test_deplete_resultslist.py index 175f75b210..4d8808c2fa 100644 --- a/tests/unit_tests/test_deplete_resultslist.py +++ b/tests/unit_tests/test_deplete_resultslist.py @@ -77,7 +77,7 @@ def test_get_steps(unit): results = openmc.deplete.Results() # Time in units of unit times = np.linspace(0, 100, num=5) - if unit == "y": + if unit == "a": conversion_to_seconds = 60 * 60 * 24 * 365.25 elif unit == "d": conversion_to_seconds = 60 * 60 * 24