From d0a2cbb0db8b47b6ceadaff26d2ede7a37d2fdf1 Mon Sep 17 00:00:00 2001 From: HeshamTB Date: Tue, 25 Jan 2022 22:45:45 +0300 Subject: [PATCH] cleanup Signed-off-by: HeshamTB --- basictypes.py | 3 +-- mklines.py | 17 ++++------------- 2 files changed, 5 insertions(+), 15 deletions(-) diff --git a/basictypes.py b/basictypes.py index ae36187..1586e03 100644 --- a/basictypes.py +++ b/basictypes.py @@ -56,10 +56,9 @@ class Line: self.m, self.b = self.__find_line(p1, p2) v = ValueError() if not self.__matching_wall_ids(p1, p2): - raise WallIDMismatch('Wall ID for points do not match') + raise WallIDMismatch('Wall ID for points does not match') def __find_line(self, p1:PointWithID, p2:PointWithID) -> float: - # m = ((point2[1] - point1[1])/(point2[0] - point1[0])) m = (p2.get_y() - p1.get_y()) / (p2.get_x() - p1.get_x()) # Using p1 to find b b = p1.get_y() - (m*p1.get_x()) diff --git a/mklines.py b/mklines.py index 790a63a..3738644 100644 --- a/mklines.py +++ b/mklines.py @@ -6,6 +6,7 @@ import csv import sys import math from os.path import exists as file_exists +from basictypes import PointWithID, Line def main(): @@ -29,18 +30,11 @@ def read_csv(filename: str, remove_header=False) -> list: new_row = list() if remove_header and i == 0: continue for i, val in enumerate(row): - if i == 0: new_row.append(val) + if i == 0: new_row.append(val) # Append wall_id as is else: new_row.append(float(val)) tmp_data.append(new_row) return tmp_data -def get_line_eq(point1, point2)-> tuple: - m = ((point2[1] - point1[1])/(point2[0] - point1[0])) - # y = mx + b - # b = y - mx - # Using p1 to find b - b = point1[1] - (m*point1[0]) - def valid_data(samples:list) -> bool: # Check if we have even number of samples return len(samples) % 2 == 0 @@ -57,9 +51,6 @@ def polarlist_to_cart(polar_points: list): p2 = polar_to_cart(p2[0],p2[1]) -def points_to_straight_line(): - pass - def get_filename() -> str: try: filename = sys.argv[1] @@ -68,8 +59,8 @@ def get_filename() -> str: perr('Provide target file name') return -1 -def perr(msg): - print(msg, file=sys.stderr) +def perr(*args): + print(args, file=sys.stderr) if __name__ == '__main__': exit(main()) \ No newline at end of file