def test_cmap_file_jscm(self): cmap_path = path.join(dirpath, 'data/cm_rainforest_jscm.jscm') if PY2: with pytest.raises(ValueError): import_cmaps(cmap_path) else: import_cmaps(cmap_path)
def test_cyclic_cmap(self): name = 'cyclic' import_cmaps(path.join(dirpath, 'data/cm_{0}.txt'.format(name))) for cmap in [name, name+'_r', name+'_shifted', name+'_shifted_r']: assert 'cmr.'+cmap in plt.colormaps() assert getattr(cmrcm, cmap, None) is not None assert cmap in cmrcm.cmap_d assert cmap in cmrcm.cmap_cd['cyclic']
def test_cyclic_cmap(self): name = 'cyclic' import_cmaps(path.join(dirpath, 'data/cm_{0}.txt'.format(name))) for cmap in [ name, name + '_r', name + '_shifted', name + '_shifted_r' ]: assert 'cmr.' + cmap in mplcm.cmap_d assert cmap in cmrcm.cmap_d assert cmap in cmrcm.cmap_cd['cyclic']
def test_invalid_cmap_npy_file(self): with pytest.raises(ValueError): import_cmaps(path.join(dirpath, 'data/cm_test2.npy'))
def test_invalid_cmap_file(self): with pytest.raises(OSError): import_cmaps(path.join(dirpath, 'data/test.txt'))
def test_non_existing_dir(self): with pytest.raises(OSError): import_cmaps('./test')
def test_cmap_file_txt(self): import_cmaps(path.join(dirpath, '../colormaps/cm_rainforest.txt'))
def test_invalid_cmap_dir(self): with pytest.raises(ValueError): import_cmaps(path.join(dirpath, 'data'))
ax.xaxis.set_visible(False) ax.yaxis.set_visible(False) plt.savefig("{0}/{0}.png".format(name), dpi=200, bbox_inches='tight', pad_inches=0) plt.close(fig) # Create txt-file with colormap data np.savetxt("cm_{0}.txt".format(name), cmap_mod.cm_data) # Delete the created __pycache__ in the loaded cmap module shutil.rmtree("{0}/__pycache__".format(name), ignore_errors=True) # Load in all colormaps currently defined import_cmaps('.') # Make new colormap overview create_cmap_overview(savefig='cmap_overview.png') # Make string with the docs entry and print it docs_entry = dedent(""" {0} {2} .. figure:: ../../../cmasher/colormaps/{1}/{1}.png :alt: Visual representation of the *{1}* colormap. :width: 100% :align: center :name: {1}_cmap .. figure:: ../../../cmasher/colormaps/{1}/{1}_viscm.png
def test_cmap_file_jscm(self): cmap_path = path.join(dirpath, 'data/cm_rainforest_jscm.jscm') import_cmaps(cmap_path)
def test_cmap_file_HEX(self): import_cmaps(path.join(dirpath, 'data/cm_hex.txt'))
def test_cmap_file_8bit(self): import_cmaps(path.join(dirpath, 'data/cm_8bit.txt'))