aboutsummaryrefslogtreecommitdiffstats
path: root/resources/tools/presentation/new/jumpavg/BitCountingClassifier.py
diff options
context:
space:
mode:
authorVratko Polak <vrpolak@cisco.com>2018-06-13 13:04:01 +0200
committerTibor Frank <tifrank@cisco.com>2018-06-15 10:16:43 +0000
commita2a0ab1cdec3567dcad46c2000337707777aa0ca (patch)
tree8d6147d2fda535c5c32c432a4ea7f3ec3124c8d9 /resources/tools/presentation/new/jumpavg/BitCountingClassifier.py
parent5120b1082aa70f6e75511e9d95a2a7c303e25f9a (diff)
CSIT-1110: Prepare for migrating the new detection
+ Do not declare BitCountingClassifier.classify() as class method. + Make BitCountingGroupList subclass of list. + Inherit from abstract classes whenever possible. + Drop unneeded imports. + Add module docstrings and class docstrings anywhere. + Add TODOs hinting at possible improvements. Change-Id: Iccfff5c0e7be0607d6cfa74314083fcfe5a4d7d9 Signed-off-by: Vratko Polak <vrpolak@cisco.com>
Diffstat (limited to 'resources/tools/presentation/new/jumpavg/BitCountingClassifier.py')
-rw-r--r--resources/tools/presentation/new/jumpavg/BitCountingClassifier.py19
1 files changed, 13 insertions, 6 deletions
diff --git a/resources/tools/presentation/new/jumpavg/BitCountingClassifier.py b/resources/tools/presentation/new/jumpavg/BitCountingClassifier.py
index 69b1d65bb2..9a723199d2 100644
--- a/resources/tools/presentation/new/jumpavg/BitCountingClassifier.py
+++ b/resources/tools/presentation/new/jumpavg/BitCountingClassifier.py
@@ -11,24 +11,31 @@
# See the License for the specific language governing permissions and
# limitations under the License.
+"""Module holding BitCountingClassifier class.
+
+This is the main class to be used by callers."""
+
+from AbstractGroupClassifier import AbstractGroupClassifier
from BitCountingGroup import BitCountingGroup
from BitCountingGroupList import BitCountingGroupList
from BitCountingMetadataFactory import BitCountingMetadataFactory
from ClassifiedMetadataFactory import ClassifiedMetadataFactory
-class BitCountingClassifier(object):
+class BitCountingClassifier(AbstractGroupClassifier):
+ """Classifier using Minimal Description Length principle."""
- @staticmethod
- def classify(values):
+ def classify(self, values):
"""Return the values in groups of optimal bit count.
- TODO: Could we return BitCountingGroupList and let caller process it?
+ The current implementation could be a static method,
+ but we might support options in later versions,
+ for example for chosing encodings.
:param values: Sequence of runs to classify.
:type values: Iterable of float or of AvgStdevMetadata
:returns: Classified group list.
- :rtype: list of BitCountingGroup
+ :rtype: BitCountingGroupList
"""
max_value = BitCountingMetadataFactory.find_max_value(values)
factory = BitCountingMetadataFactory(max_value)
@@ -60,4 +67,4 @@ class BitCountingClassifier(object):
group.metadata = ClassifiedMetadataFactory.with_classification(
group.metadata, "progression")
previous_average = group.metadata.avg
- return partition.group_list
+ return partition