def test_get_cmaps_registers_snap_color(self): ensure_cmaps_loaded() cmap_name = os.path.join(os.path.dirname(__file__), 'chl_DeM2_200.cpd') cmap = _get_custom_colormap(cmap_name) cm.register_cmap(cmap=cmap) self.assertTrue((type(cmap) is LinearSegmentedColormap) or (type(cmap) is ListedColormap))
def test_get_cmaps_registers_ivalid_snap_color(self): ensure_cmaps_loaded() cmap_name = os.path.join(os.path.dirname(__file__), 'chl_DeM2_200_invalid_for_testing.cpd') with self.assertRaises(ValueError): cmap = _get_custom_colormap(cmap_name) cm.register_cmap(cmap=cmap)
def test_get_cmap(self): ensure_cmaps_loaded() cmap_name, cmap = get_cmap('plasma') self.assertEqual('plasma', cmap_name) self.assertIsInstance(cmap, Colormap) cmap_name, cmap = get_cmap('PLASMA') self.assertEqual('viridis', cmap_name) self.assertIsInstance(cmap, Colormap) cmap_name, cmap = get_cmap('PLASMA', default_cmap_name='magma') self.assertEqual('magma', cmap_name) self.assertIsInstance(cmap, Colormap) with self.assertRaises(ValueError): get_cmap('PLASMA', default_cmap_name='MAGMA')
def test_get_cmaps_registers_ocean_colour(self): ensure_cmaps_loaded() cmap = cm.get_cmap('deep', 256) self.assertTrue((type(cmap) is LinearSegmentedColormap) or (type(cmap) is ListedColormap))
def test_get_cmaps_registers_nonexisting_snap_color(self): ensure_cmaps_loaded() cmap_name = 'test/webapi/im/chl_DeM2_200_not_existing.cpd' with self.assertRaises(ValueError): cmap = _get_custom_colormap(cmap_name) cm.register_cmap(cmap=cmap)