From 62603c5f427828dc9b083b6d05d642a9392832a7 Mon Sep 17 00:00:00 2001 From: uday Date: Thu, 5 Dec 2024 00:21:00 +0900 Subject: [PATCH] # bug changes --- .../FindNeighboursUsingEuclidean.py | 2 +- .../neighbours/FindNeighboursUsingGeodesic.py | 43 ++++++++++++++----- 2 files changed, 34 insertions(+), 11 deletions(-) diff --git a/PAMI/extras/neighbours/FindNeighboursUsingEuclidean.py b/PAMI/extras/neighbours/FindNeighboursUsingEuclidean.py index ba7ed15f..d87ee015 100644 --- a/PAMI/extras/neighbours/FindNeighboursUsingEuclidean.py +++ b/PAMI/extras/neighbours/FindNeighboursUsingEuclidean.py @@ -99,7 +99,7 @@ def create(self): self.result[tuple(firstCoordinate)].append(secondCoordinate) self._endTime = time.time() - def save(oFile: str) -> None: + def save(self,oFile: str) -> None: with open(oFile, "w+") as f: for i in self.result: string = "Point(" + i[0] + " " + i[1] + ")" + self.seperator diff --git a/PAMI/extras/neighbours/FindNeighboursUsingGeodesic.py b/PAMI/extras/neighbours/FindNeighboursUsingGeodesic.py index f5b56d29..ad9765fe 100644 --- a/PAMI/extras/neighbours/FindNeighboursUsingGeodesic.py +++ b/PAMI/extras/neighbours/FindNeighboursUsingGeodesic.py @@ -11,8 +11,6 @@ # - - __copyright__ = """ Copyright (C) 2021 Rage Uday Kiran @@ -29,11 +27,14 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . """ -import sys + import re from geopy.distance import geodesic import time -import sys, psutil, os +import sys +import psutil +import os + class FindNeighboursUsingGeodesic: """ @@ -43,8 +44,6 @@ class FindNeighboursUsingGeodesic: :param iFile : file Input file name or path of the input file - :param oFile : file - Output file name or path pf the output file :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 @@ -71,14 +70,15 @@ class FindNeighboursUsingGeodesic: obj.save() """ - def __init__(self, iFile: str, maxDist: float, sep='\t'): + def __init__(self, iFile: str, maxDist: float, sep='\t'): self.iFile = iFile self.maxGeodesicDistance = maxDist self.seperator = sep + self.result = {} - def create(self)->None: + def create(self) -> None: + self._startTime = time.time() coordinates = [] - self.result = {} with open(self.iFile, "r") as f: for line in f: l = line.rstrip().split(self.seperator) @@ -101,8 +101,9 @@ def create(self)->None: if dist <= float(self.maxGeodesicDistance): self.result[tuple(firstCoordinate)] = self.result.get(tuple(firstCoordinate), []) self.result[tuple(firstCoordinate)].append(secondCoordinate) + self._endTime = time.time() - def save(self,oFile:str)->None: + def save(self, oFile: str) -> None: with open(oFile, "w+") as f: for i in self.result: string = "Point(" + i[0] + " " + i[1] + ")" + self.seperator @@ -112,6 +113,28 @@ def save(self,oFile:str)->None: f.write(string) f.write("\n") + def getRuntime(self) -> float: + """ + Get the runtime of the transactional database + + :return: the runtime of the transactional database + + + :rtype: float + """ + return self._endTime - self._startTime + + def getMemoryUSS(self) -> float: + + process = psutil.Process(os.getpid()) + self._memoryUSS = process.memory_full_info().uss + return self._memoryUSS + + def getMemoryRSS(self) -> float: + + process = psutil.Process(os.getpid()) + self._memoryRSS = process.memory_info().rss + return self._memoryRSS if __name__ == "__main__":