Skip to content

Commit 2b485be

Browse files
committed
fix: doctest comparisons
1 parent 003e10c commit 2b485be

File tree

6 files changed

+30
-27
lines changed

6 files changed

+30
-27
lines changed

mindboggle/guts/compute.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -211,10 +211,10 @@ def pairwise_vector_distances(vectors, save_file=False, normalize=False):
211211
... save_file, normalize)
212212
>>> print(np.array_str(np.array(vector_distances),
213213
... precision=5, suppress_small=True))
214-
[[ 0. 0.8165 0.89753 0.74536]
215-
[ 0. 0. 0.16667 1.52753]
216-
[ 0. 0. 0. 1.60728]
217-
[ 0. 0. 0. 0. ]]
214+
[[0. 0.8165 0.89753 0.74536]
215+
[0. 0. 0.16667 1.52753]
216+
[0. 0. 0. 1.60728]
217+
[0. 0. 0. 0. ]]
218218
219219
"""
220220
import os

mindboggle/guts/graph.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ def diagonal_degree_matrix(W, inverse=False, square_root=False):
4040
>>> from mindboggle.guts.graph import diagonal_degree_matrix
4141
>>> W = np.array([[10,2.3,3], [0,0,3], [0,1.5,0]])
4242
>>> tocsr = diagonal_degree_matrix(W, inverse=False, square_root=False)
43-
>>> tocsr.data
44-
array([ 15.3, 3. , 1.5])
43+
>>> np.allclose(tocsr.data, [ 15.3, 3. , 1.5])
44+
True
4545
4646
"""
4747
import numpy as np
@@ -109,8 +109,8 @@ def weight_graph(Nodes, Indices, Meshes, kernel=rbf_kernel, add_to_graph=True,
109109
... add_to_graph, G, sigma, verbose)
110110
>>> G.size()
111111
9
112-
>>> G.degree()
113-
DegreeView({0.0: 4, 1.0: 4, 2.0: 3, 3.0: 4, 4.0: 3})
112+
>>> sorted(dict(G.degree()).items())
113+
[(0.0, 4), (1.0, 4), (2.0, 3), (3.0, 4), (4.0, 3)]
114114
115115
"""
116116
import numpy as np

mindboggle/guts/paths.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -699,7 +699,7 @@ def smooth_skeletons(skeletons, bounds, vtk_file, likelihoods, wN_max=1.0,
699699
... bounds, vtk_file, likelihoods, wN_max, do_erode, save_file,
700700
... output_file, background_value, verbose)
701701
>>> np.where(np.array(smoothed_skeletons)!=-1)[0][0:8]
702-
array([112572, 113453, 113454, 113469, 114294, 114295, 114312, 114313])
702+
array([112572, 113435, 113454, 113469, 114294, 114295, 114296, 114312])
703703
704704
Write out vtk file and view (skip test):
705705

mindboggle/guts/segment.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ def propagate(points, faces, region, seeds, labels,
9494
>>> segments = propagate(points, faces, region, seeds, labels,
9595
... max_iters, tol, sigma, background_value, verbose)
9696
>>> np.unique(segments)[0:10]
97-
array([ -1., 3., 12., 22.])
97+
array([-1., 3., 12., 22.])
9898
>>> len_segments = [len(np.where(segments == x)[0])
9999
... for x in np.unique(segments) if x != background_value]
100100
>>> len_segments[0:10]
@@ -282,7 +282,7 @@ def segment_regions(vertices_to_segment, neighbor_lists, min_region_size=1,
282282
>>> len(np.unique(segments))
283283
122
284284
>>> np.unique(segments)[0:10]
285-
array([ -1., 1., 3., 4., 5., 6., 7., 8., 9., 11.])
285+
array([-1., 1., 3., 4., 5., 6., 7., 8., 9., 11.])
286286
>>> len_segments = [len(np.where(segments == x)[0])
287287
... for x in np.unique(segments) if x != background_value]
288288
>>> len_segments[0:10]

mindboggle/shapes/laplace_beltrami.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -89,15 +89,16 @@ def computeAB(points, faces):
8989
[ 0. 0. 0. -1.20711 0. 1.20711 0. 0. ]
9090
[ 0. 0. 0. -0.5 0. 0. 0.5 0. ]
9191
[ 0. -0.5 0. 0. 0. 0. 0. 0.5 ]]
92+
9293
>>> print(np.array_str(B.toarray(), precision=5, suppress_small=True))
93-
[[ 0.25 0.08333 0.04167 0. 0.08333 0. 0. 0.04167]
94-
[ 0.08333 0.16667 0. 0. 0.04167 0. 0. 0.04167]
95-
[ 0.04167 0. 0.16667 0.04167 0.08333 0. 0. 0. ]
96-
[ 0. 0. 0.04167 0.28452 0.10059 0.10059 0.04167 0. ]
97-
[ 0.08333 0.04167 0.08333 0.10059 0.36785 0.05893 0. 0. ]
98-
[ 0. 0. 0. 0.10059 0.05893 0.20118 0.04167 0. ]
99-
[ 0. 0. 0. 0.04167 0. 0.04167 0.08333 0. ]
100-
[ 0.04167 0.04167 0. 0. 0. 0. 0. 0.08333]]
94+
[[0.25 0.08333 0.04167 0. 0.08333 0. 0. 0.04167]
95+
[0.08333 0.16667 0. 0. 0.04167 0. 0. 0.04167]
96+
[0.04167 0. 0.16667 0.04167 0.08333 0. 0. 0. ]
97+
[0. 0. 0.04167 0.28452 0.10059 0.10059 0.04167 0. ]
98+
[0.08333 0.04167 0.08333 0.10059 0.36785 0.05893 0. 0. ]
99+
[0. 0. 0. 0.10059 0.05893 0.20118 0.04167 0. ]
100+
[0. 0. 0. 0.04167 0. 0.04167 0.08333 0. ]
101+
[0.04167 0.04167 0. 0. 0. 0. 0. 0.08333]]
101102
102103
"""
103104
import numpy as np

mindboggle/shapes/surface_shapes.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,10 @@ def area(command, surface_file, verbose=False):
4444
>>> command = os.path.join(ccode_path, 'area', 'PointAreaMain')
4545
>>> area_file = area(command, surface_file, verbose)
4646
>>> scalars, name = read_scalars(area_file)
47-
>>> [np.float("{0:.{1}f}".format(x, 5)) for x in scalars[0:8]]
48-
[0.4827, 0.39661, 0.57813, 0.70574, 0.84318, 0.57643, 0.66942, 0.7063]
47+
>>> np.allclose(scalars[0:8],
48+
... [0.48270401731, 0.39661528543, 0.57813454792, 0.70574099571,
49+
... 0.84318527207, 0.57642554119, 0.66942016035, 0.70629953593])
50+
True
4951
5052
"""
5153
import os
@@ -102,8 +104,8 @@ def travel_depth(command, surface_file, verbose=False):
102104
>>> command = os.path.join(ccode_path, 'travel_depth', 'TravelDepthMain')
103105
>>> depth_file = travel_depth(command, surface_file, verbose)
104106
>>> scalars, name = read_scalars(depth_file)
105-
>>> [np.float("{0:.{1}f}".format(x, 5)) for x in scalars[0:8]]
106-
[0.02026, 0.06009, 0.12859, 0.04564, 0.00774, 0.05284, 0.05354, 0.01316]
107+
>>> np.allclose(scalars[0:8], [0.020259869839, 0.06009166489, 0.12858575442, 0.045639221313, 0.007742772964, 0.052839111255, 0.053538904296, 0.013158746337])
108+
True
107109
108110
"""
109111
import os
@@ -158,8 +160,8 @@ def geodesic_depth(command, surface_file, verbose=False):
158160
>>> command = os.path.join(ccode_path, 'geodesic_depth', 'GeodesicDepthMain')
159161
>>> depth_file = geodesic_depth(command, surface_file, verbose)
160162
>>> scalars, name = read_scalars(depth_file)
161-
>>> [np.float("{0:.{1}f}".format(x, 5)) for x in scalars[0:8]]
162-
[0.02026, 0.06009, 0.12859, 0.04564, 0.00774, 0.05284, 0.05354, 0.01316]
163+
>>> np.allclose(scalars[0:8], [0.020259869839, 0.06009166489, 0.12858575442, 0.045639221313, 0.007742772964, 0.052839111255, 0.053538904296, 0.013158746337])
164+
True
163165
164166
"""
165167
import os
@@ -270,8 +272,8 @@ def curvature(command, method, arguments, surface_file, verbose=False):
270272
>>> mean_curvature_file, f1,f2,f3,f4 = curvature(command, method,
271273
... arguments, surface_file, verbose)
272274
>>> scalars, name = read_scalars(mean_curvature_file)
273-
>>> [np.float("{0:.{1}f}".format(x, 5)) for x in scalars[0:8]]
274-
[-5.81361, -5.9313, -6.28055, -5.621, -5.69631, -5.80399, -5.87265, -5.7107]
275+
>>> np.allclose(scalars[0:8], [-5.8136068088, -5.9312990469, -6.2805500474, -5.6210018286, -5.6963067208, -5.8039874097, -5.8726460688, -5.7106966401])
276+
True
275277
276278
"""
277279
import os

0 commit comments

Comments
 (0)