From 7210a949958c4ccced0d156a0c9c496bb1ac063a Mon Sep 17 00:00:00 2001 From: Pascal Lais Date: Mon, 9 Mar 2020 17:41:37 +0100 Subject: [PATCH] Convert sweep module and class to algorithm Since an algorithm can use more than one sweep, the sweep class doesn't fit very good as it is right now. For this reasen it got converted to a more general class named algorithm, that shall be used as parent for every individual algorithm. The exact behaviour of the algorithm is then defined in the child classes. --- sweep.py => algorithm.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) rename sweep.py => algorithm.py (96%) diff --git a/sweep.py b/algorithm.py similarity index 96% rename from sweep.py rename to algorithm.py index 3fa4ba8..cd44cad 100644 --- a/sweep.py +++ b/algorithm.py @@ -8,20 +8,18 @@ import copy import linesegment import point -class Sweep(): +class Algorithm(): "The Sweep class is the base class for each individual sweep algorithm" # pylint: disable=too-many-instance-attributes def __init__(self): - self._sss = None # The sweep status structure - self._es = None # The event structure self._input = None # The input values + self._result = None # The result of the sweep self._ready = False # If the sweep is reade to be executed self._running = False # If the sweep is currently running self._num_steps = {} # The number of steps that were needed to solve the problem - self._result = None # The result of the sweep def start(self): """Start the performing the algorithm. Return True if it was successful""" @@ -30,8 +28,10 @@ class Sweep(): return False self._running = True return True + def get_result(self): + return self._result -class SweepNearestNeighbors(Sweep): +class NearestNeighborsSweep(Algorithm): """Calculate the pair of points inside a set, that have the minimal distance between each other inside this set"""