Skip to content

Commit aecd436

Browse files
committed
Fix missing self arg and np prefix
1 parent 9145ff3 commit aecd436

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

spectral/graphics/colorscale.py

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

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

7+
import numpy as np
8+
79
class ColorScale:
810
'''
911
A color scale class to map scalar values to rgb colors. The class allows
@@ -81,15 +83,15 @@ def __call__(self, val):
8183
return self.colorTics[int((float(val) - self.min)
8284
/ self.span * self.size)]
8385

84-
def set_background_color(color):
86+
def set_background_color(self, color):
8587
'''Sets RGB color used for values below the scale minimum.
8688
8789
Arguments:
8890
8991
`color` (3-tuple): An RGB triplet
9092
'''
9193
if type(color) in (list, tuple):
92-
color = array(color)
94+
color = np.array(color)
9395
if len(color.shape) != 1 or color.shape[0] != 3:
9496
raise 'Color value must be have exactly 3 elements.'
9597
self.bgColor = color
@@ -115,18 +117,17 @@ def create_default_color_scale(ntics=0):
115117
Total number of colors in the scale. If this value is 0, no
116118
interpolated colors will be used.
117119
'''
118-
from numpy import array
119-
mycolors = array([[0, 0, 0],
120-
[0, 0, 255],
121-
[0, 255, 0],
122-
[255, 0, 0],
123-
[255, 255, 0],
124-
[255, 255, 255]])
120+
mycolors = np.array([[0, 0, 0],
121+
[0, 0, 255],
122+
[0, 255, 0],
123+
[255, 0, 0],
124+
[255, 255, 0],
125+
[255, 255, 255]])
125126

126127
if ntics != 0 and ntics < len(mycolors):
127128
raise ValueError('Any non-zero value of `ntics` must be greater than'
128129
' {}.'.format(len(mycolors)))
129-
levels = array([0., 10., 20., 30., 40., 50.])
130+
levels = np.array([0., 10., 20., 30., 40., 50.])
130131
scale = ColorScale(levels, mycolors, ntics)
131132
return scale
132133

0 commit comments

Comments
 (0)