From ee17afc6d92888b8c539a243e8d88e9245284e14 Mon Sep 17 00:00:00 2001 From: uday Date: Thu, 5 Dec 2024 00:00:16 +0900 Subject: [PATCH] # bug changes --- .../FindNeighboursUsingEuclidean.py | 20 +++++++++-------- .../neighbours/FindNeighboursUsingGeodesic.py | 22 +++++++++---------- setup.py | 2 +- 3 files changed, 23 insertions(+), 21 deletions(-) diff --git a/PAMI/extras/neighbours/FindNeighboursUsingEuclidean.py b/PAMI/extras/neighbours/FindNeighboursUsingEuclidean.py index c3932e2c..4a7f69fd 100644 --- a/PAMI/extras/neighbours/FindNeighboursUsingEuclidean.py +++ b/PAMI/extras/neighbours/FindNeighboursUsingEuclidean.py @@ -34,7 +34,7 @@ import re from math import sqrt -class findNeighboursUsingEuclidean: +class FindNeighboursUsingEuclidean: """ This class create a neighbourhood file using euclid distance. @@ -44,11 +44,11 @@ class findNeighboursUsingEuclidean: Input file name or path of the input file :param oFile : file Output file name or path pf the output file - :param maxEuclideanDistance : int + :param maxDist : int The user can specify maxEuclideanDistance. This program find pairs of values whose Euclidean distance is less than or equal to maxEucledianDistace and store the pairs. - :param seperator: str : + :param sep: str : This variable is used to distinguish items from one another in a transaction. The default seperator is tab space. However, the users can override their default separator. :Methods: @@ -69,16 +69,18 @@ class findNeighboursUsingEuclidean: obj.save() """ - def __init__(self,iFile: str,oFile: str,maxEucledianDistance: int, seperator='\t') -> None: + def __init__(self,iFile: str,oFile: str,maxDist: int, sep='\t') -> None: self.iFile = iFile self.oFile = oFile - self.maxEucledianDistance = maxEucledianDistance + self.maxEucledianDistance = maxDist + self.seperator = sep + coordinates = [] result = {} with open(self.iFile,"r") as f: for line in f: - l = line.rstrip().split(seperator) + l = line.rstrip().split(self.seperator) #print(l) l[0] = re.sub(r'[^0-9. ]', '', l[0]) coordinates.append(l[0].rstrip().split(' ')) @@ -102,10 +104,10 @@ def __init__(self,iFile: str,oFile: str,maxEucledianDistance: int, seperator='\t with open(self.oFile,"w+") as f: for i in result: - string = "Point(" +i[0]+" "+i[1] + ")"+ seperator + string = "Point(" +i[0]+" "+i[1] + ")"+ self.seperator f.write(string) for j in result[i]: - string = "Point(" + j[0] + " " + j[1] + ")"+ seperator + string = "Point(" + j[0] + " " + j[1] + ")"+ self.seperator f.write(string) f.write("\n") @@ -114,4 +116,4 @@ def getFileName(self) -> str: return self.oFile if __name__ == "__main__": - obj = findNeighboursUsingEuclidean(sys.argv[1], sys.argv[2], sys.argv[3], sys.argv[4]) + obj = FindNeighboursUsingEuclidean(sys.argv[1], sys.argv[2], sys.argv[3], sys.argv[4]) diff --git a/PAMI/extras/neighbours/FindNeighboursUsingGeodesic.py b/PAMI/extras/neighbours/FindNeighboursUsingGeodesic.py index 4619dfbb..4040961b 100644 --- a/PAMI/extras/neighbours/FindNeighboursUsingGeodesic.py +++ b/PAMI/extras/neighbours/FindNeighboursUsingGeodesic.py @@ -31,7 +31,6 @@ """ import sys import re -from math import sqrt from geopy.distance import geodesic @@ -45,11 +44,11 @@ class FindNeighboursUsingGeodesic: Input file name or path of the input file :param oFile : file Output file name or path pf the output file - :param maxDistance : float - The user can specify maxDistance in Km(Kilometers). + :param maxDist : float + The user can specify maxDist in Km(Kilometers). This program find pairs of values whose Geodesic distance is less than or equal to maxDistace and store the pairs. - :param seperator: str : + :param sep: str : This variable is used to distinguish items from one another in a transaction. The default seperator is tab space. However, the users can override their default separator. @@ -71,16 +70,17 @@ class FindNeighboursUsingGeodesic: obj.save() """ - def __init__(self, iFile: str, oFile: str, maxDistance: float, seperator='\t'): + def __init__(self, iFile: str, oFile: str, maxDist: float, sep='\t'): self.iFile = iFile self.oFile = oFile - self.maxDistance = maxDistance + self.maxGeodesicDistance = maxDist + self.seperator = sep coordinates = [] result = {} with open(self.iFile, "r") as f: for line in f: - l = line.rstrip().split(seperator) + l = line.rstrip().split(self.seperator) # print(l) l[2] = re.sub(r'[^0-9. ]', '', l[2]) coordinates.append(l[2].rstrip().split(' ')) @@ -97,16 +97,16 @@ def __init__(self, iFile: str, oFile: str, maxDistance: float, seperator='\t'): dist = geodesic((lat1, long1), (lat2, long2)).kilometers - if dist <= float(self.maxDistance): + if dist <= float(self.maxGeodesicDistance): result[tuple(firstCoordinate)] = result.get(tuple(firstCoordinate), []) result[tuple(firstCoordinate)].append(secondCoordinate) with open(self.oFile, "w+") as f: for i in result: - string = "Point(" + i[0] + " " + i[1] + ")" + seperator + string = "Point(" + i[0] + " " + i[1] + ")" + self.seperator f.write(string) for j in result[i]: - string = "Point(" + j[0] + " " + j[1] + ")" + seperator + string = "Point(" + j[0] + " " + j[1] + ")" + self.seperator f.write(string) f.write("\n") @@ -115,4 +115,4 @@ def getFileName(self): if __name__ == "__main__": - obj = FindNeighboursUsingGeodesic(sys.argv[1], sys.argv[2], sys.argv[4]) + obj = FindNeighboursUsingGeodesic(sys.argv[1], sys.argv[2], sys.argv[3], sys.argv[4]) diff --git a/setup.py b/setup.py index 87b3b339..0640a73a 100644 --- a/setup.py +++ b/setup.py @@ -5,7 +5,7 @@ setuptools.setup( name='pami', - version='2024.12.4.5', + version='2024.12.4.7', author='Rage Uday Kiran', author_email='uday.rage@gmail.com', description='This software is being developed at the University of Aizu, Aizu-Wakamatsu, Fukushima, Japan',