vcs
vcs copied to clipboard
setcolorcell does not work when no colormap is selected (2.8.0)
I have some (old) scripts where I change by hand all the colormap entries I know I will need, and therefore don't set a colormap. This used to work fine with older versions of vcs, but it is broken now.
If you don't want the user to change the default colormap (but in the case below, it seems my default colormap is viridis and not default), then you should trap this error and show an error message
>>> import vcs
>>> x = vcs.init()
>>> x.getcolormapname()
'viridis'
>>> x.setcolorcell(21,100,0,0)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/share/unix_files/cdat/miniconda2/envs/cdatm14/lib/python2.7/site-packages/vcs/Canvas.py", line 5170, in setcolorcell
a = vcs.setcolorcell(self.colormap, *args)
File "/home/share/unix_files/cdat/miniconda2/envs/cdatm14/lib/python2.7/site-packages/vcs/utils.py", line 1903, in setcolorcell
cmap = getcolormap(obj.colormap)
AttributeError: 'NoneType' object has no attribute 'colormap'
>>> x.setcolormap('viridis')
>>> x.setcolorcell(21,100,0,0)
>>>