Skip to content

Commit

Permalink
# bug changes
Browse files Browse the repository at this point in the history
  • Loading branch information
udayRage committed Dec 4, 2024
1 parent aa2e8db commit ee17afc
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 21 deletions.
20 changes: 11 additions & 9 deletions PAMI/extras/neighbours/FindNeighboursUsingEuclidean.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
import re
from math import sqrt

class findNeighboursUsingEuclidean:
class FindNeighboursUsingEuclidean:
"""
This class create a neighbourhood file using euclid distance.
Expand All @@ -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:
Expand All @@ -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(' '))
Expand All @@ -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")

Expand All @@ -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])
22 changes: 11 additions & 11 deletions PAMI/extras/neighbours/FindNeighboursUsingGeodesic.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
"""
import sys
import re
from math import sqrt
from geopy.distance import geodesic


Expand All @@ -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.
Expand All @@ -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(' '))
Expand All @@ -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")

Expand All @@ -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])
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

setuptools.setup(
name='pami',
version='2024.12.4.5',
version='2024.12.4.7',
author='Rage Uday Kiran',
author_email='[email protected]',
description='This software is being developed at the University of Aizu, Aizu-Wakamatsu, Fukushima, Japan',
Expand Down

0 comments on commit ee17afc

Please sign in to comment.