Example #1
0
 def test_to_gdal(self):
     """
     Tests converting the matplotlib ColorMap to a gdal color table
     """
     if GDAL_INSTALLED:
         cmap = ColorMap('mpl:{}'.format(self.default_mpl_cm))
         g_ct = cmap.to_gdal()
         self.assertIsInstance(g_ct, gdal.ColorTable)
Example #2
0
 def test_convert2greyscale(self):
     """
     Tests conversion to a greyscale ColorMap
     """
     cmap = ColorMap('mpl:{}'.format(self.default_mpl_cm))
     cmap_grey = cmap.convert2greyscale()
     cmap_grey.show()
     self.assertIsInstance(cmap_grey._mpl_cm, col.LinearSegmentedColormap)
Example #3
0
 def test_save_as_json(self):
     """
     Tests save ColorMap as json file
     """
     cmap = ColorMap('mpl:{}'.format(self.default_mpl_cm))
     cmap.show()
     output_path = os.path.join(self.output_path, 'json_test.json')
     cmap.save_as_json(output_path)
     cmap_read = ColorMap.from_jsonfile(output_path)
     cmap_read.show()
     self.assertIsInstance(cmap_read, ColorMap)
Example #4
0
 def test_save_as_ct(self):
     """
     Tests save ColorMap as ct file
     """
     cmap = ColorMap('mpl:{}'.format(self.default_mpl_cm))
     cmap.show()
     output_path = os.path.join(self.output_path, 'ct_test.ct')
     cmap.save_as_ct(output_path)
     if isinstance(cmap._mpl_cm, col.LinearSegmentedColormap):
         cmap_read = ColorMap.from_file(output_path, gradient=True)
     if isinstance(cmap._mpl_cm, col.ListedColormap):
         cmap_read = ColorMap.from_file(output_path, gradient=False)
     cmap_read.show()
     self.assertIsInstance(cmap_read, ColorMap)
Example #5
0
 def test_cl_cmap_from_name(self):
     """
     Tests creation of a ColorMap from user colormap directory
     """
     cmap = ColorMap('cl:{}'.format('Rainbow'))
     self.assertIsInstance(cmap, ColorMap)
Example #6
0
 def test_cc_cmap_from_name(self):
     """
     Tests creation of a ColorMap from a cc name
     """
     cmap = ColorMap('cc:{}'.format(self.default_cc_cm))
     self.assertIsInstance(cmap, ColorMap)
Example #7
0
 def test_ml_cmap_from_name(self):
     """
     Tests creation of a ColorMap from mpl name
     """
     cmap = ColorMap('mpl:{}'.format(self.default_mpl_cm))
     self.assertIsInstance(cmap, ColorMap)
Example #8
0
 def test_view(self):
     """
     Tests ploting the ColorMap
     """
     cmap = ColorMap('mpl:{}'.format(self.default_mpl_cm))
     cmap.show()