Skip to content

Commit 051a635

Browse files
FIX numpy 1.20 compatibility: np.int --> int
1 parent 5d8dba3 commit 051a635

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

surfer/tests/test_utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,15 +73,15 @@ def test_huge_cross():
7373
def test_create_color_lut():
7474
"""Test various ways of making a colormap."""
7575
# Test valid lut
76-
cmap_in = (np.random.rand(256, 4) * 255).astype(np.int)
76+
cmap_in = (np.random.rand(256, 4) * 255).astype(int)
7777
cmap_out = utils.create_color_lut(cmap_in)
7878
assert_array_equal(cmap_in, cmap_out)
7979

8080
# Test mostly valid lut
8181
cmap_in = cmap_in[:, :3]
8282
cmap_out = utils.create_color_lut(cmap_in)
8383
assert_array_equal(cmap_in, cmap_out[:, :3])
84-
assert_array_equal(cmap_out[:, 3], np.ones(256, np.int) * 255)
84+
assert_array_equal(cmap_out[:, 3], np.ones(256, int) * 255)
8585

8686
# Test named matplotlib lut
8787
cmap_out = utils.create_color_lut("BuGn_r")

surfer/utils.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ def load_curvature(self):
150150
"""Load in curvature values from the ?h.curv file."""
151151
curv_path = op.join(self.data_path, "surf", "%s.curv" % self.hemi)
152152
self.curv = nib.freesurfer.read_morph_data(curv_path)
153-
self.bin_curv = np.array(self.curv > 0, np.int)
153+
self.bin_curv = np.array(self.curv > 0, int)
154154

155155
def load_label(self, name):
156156
"""Load in a Freesurfer .label file.
@@ -163,7 +163,7 @@ def load_label(self, name):
163163
"""
164164
label = nib.freesurfer.read_label(op.join(self.data_path, 'label',
165165
'%s.%s.label' % (self.hemi, name)))
166-
label_array = np.zeros(len(self.x), np.int)
166+
label_array = np.zeros(len(self.x), int)
167167
label_array[label] = 1
168168
try:
169169
self.labels[name] = label_array
@@ -513,10 +513,10 @@ def create_color_lut(cmap, n_colors=256, center=None):
513513
if np.ndim(cmap) == 2:
514514
if cmap.shape[1] == 4:
515515
# This looks likes a LUT that's ready to go
516-
lut = cmap.astype(np.int)
516+
lut = cmap.astype(int)
517517
elif cmap.shape[1] == 3:
518518
# This looks like a LUT, but it's missing the alpha channel
519-
alpha = np.ones(len(cmap), np.int) * 255
519+
alpha = np.ones(len(cmap), int) * 255
520520
lut = np.c_[cmap, alpha]
521521

522522
return lut
@@ -548,7 +548,7 @@ def create_color_lut(cmap, n_colors=256, center=None):
548548
raise ValueError("Input %r was not valid for making a lut" % cmap)
549549

550550
# Convert from a matplotlib colormap to a lut array
551-
lut = (cmap(np.linspace(0, 1, n_colors)) * 255).astype(np.int)
551+
lut = (cmap(np.linspace(0, 1, n_colors)) * 255).astype(int)
552552

553553
return lut
554554

surfer/viz.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1457,7 +1457,7 @@ def _to_borders(self, label, hemi, borders, restrict_idx=None):
14571457
n_vertices = label.size
14581458
edges = utils.mesh_edges(self.geo[hemi].faces)
14591459
border_edges = label[edges.row] != label[edges.col]
1460-
show = np.zeros(n_vertices, dtype=np.int)
1460+
show = np.zeros(n_vertices, dtype=int)
14611461
keep_idx = np.unique(edges.row[border_edges])
14621462
if isinstance(borders, int):
14631463
for _ in range(borders):

0 commit comments

Comments
 (0)