From dfb912917b84d4df6e0b9fb30ca7d0e8d4193e85 Mon Sep 17 00:00:00 2001 From: Diego Ferigo Date: Sun, 3 Oct 2021 13:06:18 +0200 Subject: [PATCH] Fix positiveness of model randomizations --- python/gym_ignition/randomizers/model/sdf.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/python/gym_ignition/randomizers/model/sdf.py b/python/gym_ignition/randomizers/model/sdf.py index a217754e8..52b274b4f 100644 --- a/python/gym_ignition/randomizers/model/sdf.py +++ b/python/gym_ignition/randomizers/model/sdf.py @@ -297,9 +297,6 @@ def sample(self, pretty_print=False) -> str: else: raise ValueError("Distribution not recognized") - if data.force_positive: - sample = max(sample, 0.0) - # Update the value if data.method is Method.Absolute: @@ -318,6 +315,9 @@ def sample(self, pretty_print=False) -> str: else: raise ValueError("Method not recognized") + if data.force_positive: + data.element.text = str(max(float(data.element.text), 0.0)) + return etree.tostring(self._root, pretty_print=pretty_print).decode() def new_randomization(self) -> RandomizationDataBuilder: