diff options
author | Vratko Polak <vrpolak@cisco.com> | 2019-08-22 15:04:34 +0200 |
---|---|---|
committer | Peter Mikus <pmikus@cisco.com> | 2019-08-23 10:31:55 +0000 |
commit | fbbc47359e3f7b59bbd5a84d85c673374933a50a (patch) | |
tree | e0c16b9feaf7e588cbe1708a65fe7df629d03868 /resources/libraries/python/PLRsearch/log_plus.py | |
parent | 44aaf848a22b4b3b561d883b320b1424be96174b (diff) |
Improve PLRsearch yet again
Logic improvements for rls1908 and post-pylint fixes:
+ Reduce search time to 30 minutes.
+ Use average instead alternating loads.
+ Rework log/exp avg/stdev from two estimates.
+ Introduce and use pessimistic variance of dual trackers.
+ Introduce safe_exp to use when None does not skip code.
+ Use dot relative imports (instead of disabling pylint).
+ Complete docstrings for simpler functions.
+ Append docstrings to named tuples.
+ Somewhat unify docstrings related to the same arguments.
+ Slightly improve intentation.
+ State named tuples as rtype where used.
+ Add returns and rtype to __repr__ where missing.
+ Return what docstring say (or update them).
+ Explicit copying for vector and matrix values.
Change-Id: I884c68b4839c5df5e8bef95e463666599603a0ff
Signed-off-by: Vratko Polak <vrpolak@cisco.com>
Diffstat (limited to 'resources/libraries/python/PLRsearch/log_plus.py')
-rw-r--r-- | resources/libraries/python/PLRsearch/log_plus.py | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/resources/libraries/python/PLRsearch/log_plus.py b/resources/libraries/python/PLRsearch/log_plus.py index 3f21cc78d7..1c802a5599 100644 --- a/resources/libraries/python/PLRsearch/log_plus.py +++ b/resources/libraries/python/PLRsearch/log_plus.py @@ -1,4 +1,4 @@ -# Copyright (c) 2018 Cisco and/or its affiliates. +# Copyright (c) 2019 Cisco and/or its affiliates. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at: @@ -87,3 +87,16 @@ def log_minus(first, second): raise RuntimeError("log_minus: non-positive number to log") else: return first + math.log(factor) + + +def safe_exp(log_value): + """Return exponential of the argument, or zero if the argument is None. + + :param log_value: The value to exponentiate. + :type log_value: NoneType or float + :returns: The exponentiated value. + :rtype: float + """ + if log_value is None: + return 0.0 + return math.exp(log_value) |