Skip to content

Commit d49849a

Browse files
committed
fix: numerical precision checks in doctests
1 parent bef76b7 commit d49849a

File tree

2 files changed

+14
-16
lines changed

2 files changed

+14
-16
lines changed

mindboggle/mio/colors.py

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,12 @@ def distinguishable_colors(ncolors, backgrounds=[[0,0,0],[1,1,1]],
6161
>>> verbose = False
6262
>>> colors = distinguishable_colors(ncolors, backgrounds,
6363
... save_csv, plot_colormap, verbose)
64-
>>> colors[0]
65-
array([ 0.62068966, 0.06896552, 1. ])
66-
>>> colors[1]
67-
array([ 0. , 0.5862069, 0. ])
68-
>>> colors[2]
69-
array([ 0.75862069, 0.20689655, 0. ])
64+
>>> np.allclose(colors[0], [ 0.62068966, 0.06896552, 1. ])
65+
True
66+
>>> np.allclose(colors[1], [ 0. , 0.5862069, 0. ])
67+
True
68+
>>> np.allclose(colors[2], [ 0.75862069, 0.20689655, 0. ])
69+
True
7070
7171
"""
7272
import numpy as np
@@ -227,15 +227,17 @@ def label_adjacency_matrix(label_file, ignore_values=[-1, 999], add_value=0,
227227
>>> label_file = fetch_data(urls['left_manual_labels'], '', '.vtk')
228228
>>> labels, matrix, output_table = label_adjacency_matrix(label_file,
229229
... ignore_values, add_value, save_table, output_format, verbose)
230-
>>> matrix.lookup([20,21,22,23,24,25,26,27,28,29],
230+
>>> out = matrix.lookup([20,21,22,23,24,25,26,27,28,29],
231231
... [35,35,35,35,35,35,35,35,35,35])
232-
array([ 0., 1., 0., 0., 0., 0., 0., 1., 1., 1.])
232+
>>> np.allclose(out, [ 0., 1., 0., 0., 0., 0., 0., 1., 1., 1.])
233+
True
233234
234235
>>> label_file = fetch_data(urls['freesurfer_labels'], '', '.nii.gz')
235236
>>> labels, matrix, output_table = label_adjacency_matrix(label_file,
236237
... ignore_values, add_value, save_table, output_format, verbose)
237-
>>> matrix.lookup([4,5,7,8,10,11,12,13,14,15], [4,4,4,4,4,4,4,4,4,4])
238-
array([ 1., 1., 0., 0., 0., 1., 0., 0., 1., 0.])
238+
>>> out matrix.lookup([4,5,7,8,10,11,12,13,14,15], [4,4,4,4,4,4,4,4,4,4])
239+
>>> np.allclose(out, [ 1., 1., 0., 0., 0., 1., 0., 0., 1., 0.])
240+
True
239241
240242
"""
241243
import numpy as np

mindboggle/mio/tables.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -824,12 +824,8 @@ def select_column_from_tables(tables, index=0, write_table=True,
824824
>>> output = select_column_from_tables(tables, index, write_table,
825825
... output_table)
826826
>>> columns = output[1][0]
827-
>>> columns[0]
828-
2.8010000000000002
829-
>>> columns[1]
830-
3.9430000000000001
831-
>>> columns[2]
832-
4.0280000000000005
827+
>>> np.allclose(columns, [2.801, 3.943, 4.028])
828+
True
833829
834830
"""
835831
import os

0 commit comments

Comments
 (0)