Skip to content

Commit 1758d44

Browse files
authored
Merge pull request #1 from UV-CDAT/improved_getcolors
allows user to set default range to use when calling getcolors
2 parents ea2673d + 70500b6 commit 1758d44

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

vcs/utils.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
"white2yellow": "white_to_yellow",
4848
}
4949

50+
defaultColorsRange = range(256)
5051

5152
def process_range_from_old_scr(code, g):
5253
irg = code.find("range")
@@ -667,7 +668,7 @@ def scriptrun(script):
667668
exec(compile(open(script).read(), script, 'exec'))
668669
else:
669670
if os.path.split(script)[-1] == "initial.attributes":
670-
vcs._doValidation = True
671+
vcs._doValidation = False
671672
loader = {"P": 'template',
672673
"Gfb": 'boxfill',
673674
"Gfi": 'isofill',
@@ -1156,6 +1157,8 @@ def getcolors(levs, colors=None, split=1, white="white"):
11561157
represent <0 and >0 values.
11571158
If the colors are split an interval goes from <0 to >0
11581159
then this is assigned the "white" color
1160+
the default range of colors to use can be adjusted by setting:
1161+
vcs.utils.defaultColorsRange = newrange
11591162
11601163
:Example:
11611164
@@ -1173,6 +1176,9 @@ def getcolors(levs, colors=None, split=1, white="white"):
11731176
[0, 241, 128, 153, 179, 204, 230, 255]
11741177
>>> vcs.getcolors (a,white=241,split=0)
11751178
[0, 36, 73, 109, 146, 182, 219, 255]
1179+
>>> vcs.utils.defaultColorsRange = range(16,240)
1180+
>>> vcs.getcolors (a,white=241)
1181+
[16, 241, 128, 150, 172, 195, 217, 239]
11761182
11771183
11781184
:param levs: levels defining the color ranges
@@ -1196,7 +1202,7 @@ def getcolors(levs, colors=None, split=1, white="white"):
11961202
"""
11971203

11981204
if colors is None:
1199-
colors = range(256)
1205+
colors = defaultColorsRange
12001206
if len(levs) == 1:
12011207
return [colors[0]]
12021208
if isinstance(levs[0], list) or isinstance(levs[0], tuple):

0 commit comments

Comments
 (0)