Skip to content

Commit

Permalink
Lint fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
ayan-b committed Jun 24, 2020
1 parent 278d688 commit b3f9285
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 14 deletions.
23 changes: 13 additions & 10 deletions gdist.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def compute_gdist(
number_of_target_indices,
source_indices_array,
target_indices_array,
distance_limit
distance_limit,
):
target_indices_size = target_indices_array.size
distance = np.empty(target_indices_size, dtype=np.float64)
Expand All @@ -76,7 +76,7 @@ def compute_gdist(
source_indices_array,
target_indices_array,
distance,
distance_limit
distance_limit,
)
return distance

Expand All @@ -95,11 +95,14 @@ def local_gdist_matrix(
vertices,
triangles,
ctypes.byref(sparse_matrix_size),
max_distance
max_distance,
)

np_data = np.fromiter(data, dtype=np.float64,
count=3 * sparse_matrix_size.value)
np_data = np.fromiter(
data,
dtype=np.float64,
count=3 * sparse_matrix_size.value,
)
lib.free_memory(data)
return np_data

Expand All @@ -126,15 +129,15 @@ def compute_gdist(
number_of_target_indices=target_indices.size,
source_indices_array=source_indices,
target_indices_array=target_indices,
distance_limit=max_distance
distance_limit=max_distance,
)
return np.fromiter(distance, dtype=np.float64, count=target_indices.size)


def local_gdist_matrix(
vertices,
triangles,
max_distance=1e100
max_distance=1e100,
):
vertices = vertices.ravel()
triangles = triangles.ravel()
Expand All @@ -145,12 +148,12 @@ def local_gdist_matrix(
triangles.size,
vertices,
triangles,
max_distance
max_distance,
)
sizes = data.size // 3
rows = data[:sizes]
columns = data[sizes: 2*sizes]
data = data[2*sizes:]
columns = data[sizes: 2 * sizes]
data = data[2 * sizes:]

return scipy.sparse.csc_matrix(
(data, (rows, columns)), shape=(vertices.size // 3, vertices.size // 3)
Expand Down
2 changes: 0 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
"""

import os
import shutil
import sys
import setuptools

Expand All @@ -61,7 +60,6 @@
]

INCLUDE_DIRS = [
# numpy.get_include(), # NumPy dtypes
"geodesic_library", # geodesic distance, C++ library.
]

Expand Down
4 changes: 2 additions & 2 deletions tests/test_gdist.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def test_flat_triangular_mesh(self):
vertices = data[0:121].astype(np.float64)
triangles = data[121:].astype(np.int32)
distances = gdist.local_gdist_matrix(vertices, triangles)
epsilon = 1e-6 # the default value used in `assert_array_almost_equal`
epsilon = 1e-6 # the default value used in `assert_array_almost_equal`
# test if the obtained matrix is symmetric
assert (abs(distances - distances.T) > epsilon).nnz == 0
np.testing.assert_array_almost_equal(distances.toarray()[1][0], 0.2)
Expand All @@ -54,7 +54,7 @@ def test_hedgehog_mesh(self):
vertices = data[0:300].astype(np.float64)
triangles = data[300:].astype(np.int32)
distances = gdist.local_gdist_matrix(vertices, triangles)
epsilon = 1e-6 # the default value used in `assert_array_almost_equal`
epsilon = 1e-6 # the default value used in `assert_array_almost_equal`
# test if the obtained matrix is symmetric
assert (abs(distances - distances.T) > epsilon).nnz == 0
np.testing.assert_array_almost_equal(
Expand Down

0 comments on commit b3f9285

Please sign in to comment.