Skip to content

Commit

Permalink
Merge pull request #58 from ayan-b/full-cov
Browse files Browse the repository at this point in the history
Add 100% test coverage
  • Loading branch information
liadomide committed Aug 3, 2020
2 parents 13b0f09 + 9960f57 commit 03a823b
Show file tree
Hide file tree
Showing 3 changed files with 138 additions and 2 deletions.
121 changes: 121 additions & 0 deletions data/flat_triangular_mesh_no_target.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
0.000000000000000000e+00
1.999999999999999556e-01
3.999999999999999667e-01
5.999999999999998668e-01
7.999999999999998224e-01
9.999999999999997780e-01
1.199999999999999734e+00
1.399999999999999689e+00
1.599999999999999645e+00
1.799999999999999378e+00
1.999999999999999334e+00
1.999999999999999001e-01
2.828427124746188404e-01
4.472135954999578167e-01
6.324555320336756603e-01
8.246211251235316952e-01
1.019803902718556365e+00
1.216552506059643601e+00
1.414213562373094479e+00
1.612451549659709160e+00
1.811077027627482572e+00
2.009975124224177456e+00
3.999999999999998002e-01
4.472135954999576501e-01
5.656854249492377917e-01
7.211102550927973587e-01
8.944271909999156334e-01
1.077032961426900526e+00
1.264911064067351321e+00
1.456021977856102989e+00
1.649242250247063168e+00
1.843908891458576171e+00
2.039607805437112731e+00
5.999999999999999778e-01
6.324555320336757713e-01
7.211102550927979138e-01
8.485281374238569096e-01
9.999999999999996669e-01
1.166190378969059749e+00
1.341640786499873395e+00
1.523154621172781553e+00
1.708800749063505764e+00
1.897366596101026870e+00
2.088061301782109247e+00
7.999999999999997113e-01
8.246211251235318063e-01
8.944271909999155223e-01
9.999999999999997780e-01
1.131370849898475361e+00
1.280624847486569129e+00
1.442220510185595161e+00
1.612451549659709160e+00
1.788854381999831267e+00
1.969771560359220519e+00
2.154065922853801052e+00
1.000000000000000000e+00
1.019803902718556810e+00
1.077032961426900526e+00
1.166190378969059749e+00
1.280624847486569795e+00
1.414213562373094701e+00
1.562049935181330396e+00
1.720465053408524847e+00
1.886796226411320054e+00
2.059126028197399538e+00
2.236067977499788917e+00
1.200000000000000178e+00
1.216552506059644045e+00
1.264911064067351321e+00
1.341640786499873839e+00
1.442220510185595383e+00
1.562049935181331062e+00
1.697056274847713597e+00
1.843908891458577060e+00
1.999999999999999556e+00
2.163330765278392853e+00
2.332380757938119498e+00
1.399999999999999911e+00
1.414213562373094923e+00
1.456021977856103433e+00
1.523154621172781553e+00
1.612451549659709160e+00
1.720465053408524847e+00
1.843908891458577282e+00
1.979898987322332271e+00
2.126029162546929197e+00
2.280350850198275214e+00
2.441311123146739703e+00
1.600000000000000089e+00
1.612451549659709826e+00
1.649242250247064057e+00
1.708800749063505986e+00
1.788854381999831267e+00
1.886796226411320054e+00
1.999999999999999778e+00
2.126029162546929641e+00
2.262741699796951611e+00
2.408318915758458356e+00
2.561249694973138702e+00
1.799999999999999600e+00
1.811077027627482794e+00
1.843908891458577060e+00
1.897366596101026648e+00
1.969771560359220741e+00
2.059126028197399094e+00
2.163330765278392853e+00
2.280350850198275214e+00
2.408318915758458356e+00
2.545584412271570063e+00
2.690724809414740903e+00
1.999999999999999778e+00
2.009975124224177456e+00
2.039607805437113619e+00
2.088061301782109247e+00
2.154065922853801052e+00
2.236067977499788917e+00
2.332380757938119498e+00
2.441311123146739703e+00
2.561249694973138702e+00
2.690724809414741792e+00
2.828427124746188959e+00
4 changes: 2 additions & 2 deletions gdist.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -170,10 +170,10 @@ def compute_gdist(numpy.ndarray[numpy.float64_t, ndim=2] vertices,
cdef vector[unsigned] faces

if source_indices is None:
source_indices = numpy.arange(0, dtype=numpy.int32) # default to 0
source_indices = numpy.arange(1, dtype=numpy.int32) # default to 0
if target_indices is None:
propagate_on_max_distance = True
target_indices = numpy.arange(vertices.size(), dtype=numpy.int32)
target_indices = numpy.arange(vertices.shape[0], dtype=numpy.int32)

for k in vertices.flatten():
points.push_back(k)
Expand Down
15 changes: 15 additions & 0 deletions tests/test_gdist.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,21 @@ def test_flat_triangular_mesh_1_indexed(self):
)
np.testing.assert_array_almost_equal(distance, [0.2])

def test_flat_triangular_mesh_no_target(self):
data = np.loadtxt("data/flat_triangular_mesh.txt", skiprows=1)
vertices = data[0:121].astype(np.float64)
triangles = data[121:].astype(np.int32)
source = None
target = None
distance = gdist.compute_gdist(
vertices,
triangles,
source,
target,
)
expected = np.loadtxt("data/flat_triangular_mesh_no_target.txt")
np.testing.assert_array_almost_equal(distance, expected)

def test_hedgehog_mesh(self):
data = np.loadtxt("data/hedgehog_mesh.txt", skiprows=1)
vertices = data[0:300].astype(np.float64)
Expand Down

0 comments on commit 03a823b

Please sign in to comment.