Skip to content

Commit 79a9db6

Browse files
authored
Fix deprecation warnings caused by np.int and np.float (#130)
Replaced with int, float and np.int8 as appropriate (closes #129).
1 parent cf84aeb commit 79a9db6

File tree

6 files changed

+12
-13
lines changed

6 files changed

+12
-13
lines changed

spectral/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
from __future__ import absolute_import, division, print_function, unicode_literals
66

7-
__version__ = '0.22.2'
7+
__version__ = '0.22.3'
88

99
import sys
1010
if sys.byteorder == 'little':

spectral/config.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,5 +157,4 @@ class SpySettings:
157157
[100, 0, 100],
158158
[200, 0, 200],
159159
[0, 100, 100],
160-
[0, 200, 200]], np.int)
161-
160+
[0, 200, 200]], np.int8)

spectral/graphics/colorscale.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,13 @@ def __init__(self, levels, colors, num_tics=0):
5252
if type(levels) in (list, tuple):
5353
levels = [float(x) for x in levels]
5454
elif isinstance(levels, np.ndarray):
55-
levels = levels.astype(np.float)
55+
levels = levels.astype(float)
5656

5757
self.span = levels[-1] - levels[0]
5858
self.max = levels[-1]
5959
self.min = levels[0]
6060
self.tics = np.linspace(self.min, self.max, num_tics)
61-
self.colorTics = np.zeros((len(self.tics), 3), np.int)
61+
self.colorTics = np.zeros((len(self.tics), 3), int)
6262
self.size = len(self.tics)
6363
self.bgColor = np.array([0, 0, 0])
6464

@@ -71,7 +71,7 @@ def __init__(self, levels, colors, num_tics=0):
7171
dcolor = colors[j] - colors[j - 1]
7272
dlevel = levels[j] - levels[j - 1]
7373
self.colorTics[i] = (colors[j - 1] + (self.tics[i] - levels[j - 1])
74-
/ dlevel * dcolor).astype(np.int)
74+
/ dlevel * dcolor).astype(int)
7575

7676
def __call__(self, val):
7777
'''Returns the scale color associated with the given value.'''

spectral/graphics/graphics.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -566,7 +566,7 @@ def get_rgb_meta(source, bands=None, **kwargs):
566566
# Pick the first, middle, and last bands
567567
n = source.shape[-1]
568568
bands = [0, n // 2, n - 1]
569-
rgb = source.read_bands(bands).astype(np.float)
569+
rgb = source.read_bands(bands).astype(float)
570570
meta['bands'] = bands
571571
else:
572572
# It should be a numpy array
@@ -587,7 +587,7 @@ def get_rgb_meta(source, bands=None, **kwargs):
587587
# first, middle, & last bands.
588588
bands = [0, s[2] / 2, s[2] - 1]
589589

590-
rgb = np.take(source, bands, 2).astype(np.float)
590+
rgb = np.take(source, bands, 2).astype(float)
591591
if rgb.ndim == 2:
592592
rgb = rgb[:, :, np.newaxis]
593593
meta['bands'] = bands
@@ -614,14 +614,14 @@ def get_rgb_meta(source, bands=None, **kwargs):
614614
scale.set_range(min(rgb.ravel()), max(rgb.ravel()))
615615
rgb3 = np.zeros((s[0], s[1], 3), int)
616616
rgb3 = np.apply_along_axis(scale, 2, rgb)
617-
rgb = rgb3.astype(np.float) / 255.
617+
rgb = rgb3.astype(float) / 255.
618618
return (_fill_mask(rgb, mask, bg), meta)
619619
else:
620620
# Only one band of data to display but still need to determine how
621621
# to scale the data values
622622
meta['mode'] = 'monochrome'
623623
monochrome = True
624-
rgb = np.repeat(rgb, 3, 2).astype(np.float)
624+
rgb = np.repeat(rgb, 3, 2).astype(float)
625625

626626
# Perform any requested color enhancements.
627627

spectral/graphics/ndwindow.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ def __init__(self, data, parent, id, *args, **kwargs):
348348

349349
self.data = data
350350
self.classes = kwargs.get('classes',
351-
np.zeros(data.shape[:-1], np.int))
351+
np.zeros(data.shape[:-1], int))
352352
self.features = kwargs.get('features', list(range(6)))
353353
self.labels = kwargs.get('labels', list(range(data.shape[-1])))
354354
self.max_menu_class = int(np.max(self.classes.ravel() + 1))

spectral/io/spyfile.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -550,8 +550,8 @@ def tile_image(im, nrows, ncols):
550550
contains nrows lists, each of which contains
551551
ncols SubImage objects.
552552
'''
553-
x = (np.array(list(range(nrows + 1))) * float(im.nrows) / nrows).astype(np.int)
554-
y = (np.array(list(range(ncols + 1))) * float(im.ncols) / ncols).astype(np.int)
553+
x = (np.array(list(range(nrows + 1))) * float(im.nrows) / nrows).astype(int)
554+
y = (np.array(list(range(ncols + 1))) * float(im.ncols) / ncols).astype(int)
555555
x[-1] = im.nrows
556556
y[-1] = im.ncols
557557

0 commit comments

Comments
 (0)