This is merely a historical archive of years 2008-2021, before the migration to mailman3.
A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.
Holger Freyther gerrit-no-reply at lists.osmocom.orgReview at https://gerrit.osmocom.org/6231 cdf: Add API to scale percent to target value We want to start 10k of instances and it is easier to have the necessary conversion from percent to number in the CDF function. Change-Id: I9d5b63909eef3d592aec6d51452f3b1811d8cc07 --- M src/osmo_ms_driver/cdf.py 1 file changed, 48 insertions(+), 0 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-gsm-tester refs/changes/31/6231/1 diff --git a/src/osmo_ms_driver/cdf.py b/src/osmo_ms_driver/cdf.py index fbdc05f..e84d9c7 100644 --- a/src/osmo_ms_driver/cdf.py +++ b/src/osmo_ms_driver/cdf.py @@ -37,12 +37,22 @@ self._fun = fun self._x = 0.0 self._y = self._fun(self._x) + self._target = 1.0 + + def set_target(self, scale): + """ + Scale the percentage to the target value.. + """ + self._target = scale def is_done(self): return self._y >= 1.0 def current_value(self): return self._y + + def current_scaled_value(self): + return self._y * self._target def step_once(self): self._x = self._x + self._step.total_seconds() @@ -95,6 +105,44 @@ 1.0... >>> a.is_done() True + + >>> a = linear_with_duration(timedelta(seconds=10), step_size=timedelta(seconds=2)) + >>> a.set_target(1000) + >>> a.is_done() + False + >>> a.current_value() + 0.0 + >>> a.current_scaled_value() + 0.0 + >>> a.step_once() + >>> a.current_value() + 0.2 + >>> a.current_scaled_value() + 200.0 + >>> a.step_once() + >>> a.current_value() + 0.4 + >>> a.current_scaled_value() + 400.0 + >>> a.step_once() + >>> a.current_value() + 0.6... + >>> a.current_scaled_value() + 600.0... + >>> a.step_once() + >>> a.current_value() + 0.8... + >>> a.current_scaled_value() + 800.0... + >>> a.is_done() + False + >>> a.step_once() + >>> a.current_value() + 1.0... + >>> a.current_scaled_value() + 1000.0... + >>> a.is_done() + True """ slope = 1.0/duration.total_seconds() return linear_with_slope(slope, step_size) -- To view, visit https://gerrit.osmocom.org/6231 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I9d5b63909eef3d592aec6d51452f3b1811d8cc07 Gerrit-PatchSet: 1 Gerrit-Project: osmo-gsm-tester Gerrit-Branch: master Gerrit-Owner: Holger Freyther <holger at freyther.de>