def testGetDict(self): """Test the getDict function API""" clmObject = Colormap(name='viridis', normalization=Colormap.LINEAR, vmin=self.vmin, vmax=self.vmax) clmDict = clmObject._toDict() self.assertTrue(clmDict['name'] == 'viridis') self.assertTrue(clmDict['autoscale'] is False) self.assertTrue(clmDict['vmin'] == self.vmin) self.assertTrue(clmDict['vmax'] == self.vmax) self.assertTrue(clmDict['normalization'] == Colormap.LINEAR) clmObject.setVRange(None, None) self.assertTrue(clmObject._toDict()['autoscale'] is True)
def testEditableMode(self): """Make sure the colormap will raise NotEditableError when try to change a colormap not editable""" colormap = Colormap() colormap.setEditable(False) with self.assertRaises(NotEditableError): colormap.setVRange(0., 1.) with self.assertRaises(NotEditableError): colormap.setVMin(1.) with self.assertRaises(NotEditableError): colormap.setVMax(1.) with self.assertRaises(NotEditableError): colormap.setNormalization(Colormap.LOGARITHM) with self.assertRaises(NotEditableError): colormap.setName('magma') with self.assertRaises(NotEditableError): colormap.setColormapLUT([[0., 0., 0.], [1., 1., 1.]]) with self.assertRaises(NotEditableError): colormap._setFromDict(colormap._toDict()) state = colormap.saveState() with self.assertRaises(NotEditableError): colormap.restoreState(state)
def testEditableMode(self): """Make sure the colormap will raise NotEditableError when try to change a colormap not editable""" colormap = Colormap() colormap.setEditable(False) with self.assertRaises(NotEditableError): colormap.setVRange(0., 1.) with self.assertRaises(NotEditableError): colormap.setVMin(1.) with self.assertRaises(NotEditableError): colormap.setVMax(1.) with self.assertRaises(NotEditableError): colormap.setNormalization(Colormap.LOGARITHM) with self.assertRaises(NotEditableError): colormap.setName('magma') with self.assertRaises(NotEditableError): colormap.setColormapLUT(numpy.array([0, 1])) with self.assertRaises(NotEditableError): colormap._setFromDict(colormap._toDict()) state = colormap.saveState() with self.assertRaises(NotEditableError): colormap.restoreState(state)