From 0fb571ba2b6438894828b083e6f64a72c641c53f Mon Sep 17 00:00:00 2001 From: Rick Staa Date: Tue, 8 Aug 2023 16:15:16 +0200 Subject: [PATCH] test: improve test precision function (#285) --- stable_gym/common/utils.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/stable_gym/common/utils.py b/stable_gym/common/utils.py index cc0578da..d266205e 100644 --- a/stable_gym/common/utils.py +++ b/stable_gym/common/utils.py @@ -325,17 +325,19 @@ def convert_gym_box_to_gymnasium_box(gym_box_space): ) -def change_precision(input_value, precision=8): +def change_precision(input_value, precision=16): """Changes the precision of a value. Args: input_value (object): The input value. precision (int, optional): The precision (i.e. number of decimals) to use. - Defaults to ``8``. + Defaults to ``16``. If ``None``, the input value is returned as is. Returns: object: The input value with the new precision. """ + if precision is None: + return input_value if isinstance(input_value, dict): for key, value in input_value.items(): input_value[key] = change_precision(value, precision)