diff --git a/.codecov.yml b/.codecov.yml index fe85313..2a6f25d 100644 --- a/.codecov.yml +++ b/.codecov.yml @@ -1,2 +1,7 @@ ignore: - - "main.py" \ No newline at end of file + - "main.py" + +status: +project: + default: + target:90% \ No newline at end of file diff --git a/structure.py b/structure.py index 5c268f5..e4ba74b 100644 --- a/structure.py +++ b/structure.py @@ -279,12 +279,12 @@ def NLateration(data, step=.1, xSize=0.0, ySize=0.0, zSize=0.0): :param zSize: The Z dimension of the cuboid containing all the emitters (automatically computed if not specified) ''' minLoc = Location() - minDist = xMax = yMax = zMax = 0.0 + minDist = 0.0 for k in data: minDist += abs(k[0].distanceTo(Location()) - k[1]) - xMax = k[0].x if k[0].x > xMax and not xSize else k[0].x - yMax = k[0].y if k[0].y > yMax and not ySize else k[0].y - zMax = k[0].z if k[0].z > zMax and not zSize else k[0].z + xSize = k[0].x if k[0].x > xSize else xSize + ySize = k[0].y if k[0].y > ySize else ySize + zSize = k[0].z if k[0].z > zSize else zSize for k in arange(0.1,xSize,step): for l in arange(0.1,ySize,step): for m in arange(0.1,zSize,step): @@ -294,4 +294,5 @@ def NLateration(data, step=.1, xSize=0.0, ySize=0.0, zSize=0.0): if d < minDist: minDist = d minLoc = Location(round(k,2),round(l,2),round(m,2)) - return (minLoc, minDist) \ No newline at end of file + return (minLoc, minDist) + \ No newline at end of file diff --git a/test_structure.py b/test_structure.py index 197e829..a5fb770 100644 --- a/test_structure.py +++ b/test_structure.py @@ -1,7 +1,9 @@ -from structure import KNeighbors, resolve_barycenter, Location, newCell, MarkovModel, RSSVector +from structure import KNeighbors, resolve_barycenter, Location, newCell, MarkovModel, RSSVector, NLateration from io import StringIO import sys +testEmitters = [(Location(.5,.5,.5), 3.0), (Location(4.0,.0,.0), 2.0), (Location(4.0,5.0,5.0), 4.2), (Location(3.0,3.0,3.0), 2.5)] + Tf = [[newCell(-38,-27,-54,-13,2,2),newCell(-74,-62,-48,-33,2,6),newCell(-13,-28,-12,-40,2,10) ],\ [newCell(-34,-27,-38,-41,6,2), newCell(-64,-48,-72,-35,6,6), newCell(-45,-37,-20,-15,6,10)], \ [newCell(-17,-50,-44,-33,10,2), newCell(-27,-28,-32,-45,10,6), newCell(-30,-20,-60,-40,10,10)]] @@ -97,7 +99,10 @@ def test_printPercentage(): assert len(output.out) > 2000 print(len(output.out)) - +def test_NLateration(): + test_result = NLateration(testEmitters) + assert test_result[0] == Location(3.3, 1.5, 1.1) + assert round(test_result[1],2) == 1.19 class OutputBuffer(object): def __init__(self): -- libgit2 0.21.4