aboutsummaryrefslogtreecommitdiffstats
path: root/resources/libraries/python/MLRsearch/NdrPdrResult.py
diff options
context:
space:
mode:
authorJan Gelety <jgelety@cisco.com>2019-11-12 05:27:43 +0100
committerJan Gelety <jgelety@cisco.com>2019-11-28 18:26:21 +0100
commitd68951ac245150eeefa6e0f4156e4c1b5c9e9325 (patch)
tree487554a7547218d27f0a61ec02b70502c32cdcb4 /resources/libraries/python/MLRsearch/NdrPdrResult.py
parented0258a440cfad7023d643f717ab78ac568dc59b (diff)
Python3: resources and libraries
Change-Id: I1392c06b1d64f62b141d24c0d42a8e36913b15e2 Signed-off-by: Jan Gelety <jgelety@cisco.com>
Diffstat (limited to 'resources/libraries/python/MLRsearch/NdrPdrResult.py')
-rw-r--r--resources/libraries/python/MLRsearch/NdrPdrResult.py27
1 files changed, 13 insertions, 14 deletions
diff --git a/resources/libraries/python/MLRsearch/NdrPdrResult.py b/resources/libraries/python/MLRsearch/NdrPdrResult.py
index 7b8cfd6449..3454ef1957 100644
--- a/resources/libraries/python/MLRsearch/NdrPdrResult.py
+++ b/resources/libraries/python/MLRsearch/NdrPdrResult.py
@@ -13,11 +13,10 @@
"""Module defining NdrPdrResult class."""
-from resources.libraries.python.MLRsearch.ReceiveRateInterval \
- import ReceiveRateInterval
+from .ReceiveRateInterval import ReceiveRateInterval
-class NdrPdrResult(object):
+class NdrPdrResult:
"""Two measurement intervals, return value of search algorithms.
Partial fraction is NOT part of the result. Pdr interval should be valid
@@ -34,11 +33,13 @@ class NdrPdrResult(object):
# TODO: Type checking is not very pythonic,
# perhaps users can fix wrong usage without it?
if not isinstance(ndr_interval, ReceiveRateInterval):
- raise TypeError("ndr_interval, is not a ReceiveRateInterval: "
- "{ndr!r}".format(ndr=ndr_interval))
+ raise TypeError(
+ f"ndr_interval, is not a ReceiveRateInterval: {ndr_interval!r}"
+ )
if not isinstance(pdr_interval, ReceiveRateInterval):
- raise TypeError("pdr_interval, is not a ReceiveRateInterval: "
- "{pdr!r}".format(pdr=pdr_interval))
+ raise TypeError(
+ f"pdr_interval, is not a ReceiveRateInterval: {pdr_interval!r}"
+ )
self.ndr_interval = ndr_interval
self.pdr_interval = pdr_interval
@@ -51,16 +52,14 @@ class NdrPdrResult(object):
:returns: Message containing NDR and PDR widths in goals.
:rtype: str
"""
- return "ndr {ndr_in_goals}; pdr {pdr_in_goals}".format(
- ndr_in_goals=self.ndr_interval.width_in_goals(relative_width_goal),
- pdr_in_goals=self.pdr_interval.width_in_goals(relative_width_goal))
+ return f"ndr {self.ndr_interval.width_in_goals(relative_width_goal)};" \
+ f" pdr {self.pdr_interval.width_in_goals(relative_width_goal)}"
def __str__(self):
"""Return string as tuple of named values."""
- return "NDR={ndr!s};PDR={pdr!s}".format(
- ndr=self.ndr_interval, pdr=self.pdr_interval)
+ return f"NDR={self.ndr_interval!s};PDR={self.pdr_interval!s}"
def __repr__(self):
"""Return string evaluable as a constructor call."""
- return "NdrPdrResult(ndr_interval={ndr!r},pdr_interval={pdr!r})".format(
- ndr=self.ndr_interval, pdr=self.pdr_interval)
+ return f"NdrPdrResult(ndr_interval={self.ndr_interval!r}," \
+ f"pdr_interval={self.pdr_interval!r})"