From a2a0ab1cdec3567dcad46c2000337707777aa0ca Mon Sep 17 00:00:00 2001 From: Vratko Polak Date: Wed, 13 Jun 2018 13:04:01 +0200 Subject: 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 --- .../presentation/new/jumpavg/BitCountingClassifier.py | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'resources/tools/presentation/new/jumpavg/BitCountingClassifier.py') 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 -- cgit 1.2.3-korg