class_docstr: Test utilities used with colormaps.
class_docstr_tok: ["Test","utilities","used","with","colormaps","."]
docstr: Test that colormaps can be loaded from a binary file.
code: def test_cmap_from_file(
      self, color_scale, colormap_mode, extra_kwargs, filename_suffix
  ):
      """Test that colormaps can be loaded from a binary file."""
      # create the colormap file on disk
      with closed_named_temp_file(
          suffix=filename_suffix
      ) as cmap_filename:
          cmap_data = _generate_cmap_test_data(
              color_scale, colormap_mode
          )
          _write_cmap_to_file(cmap_filename, cmap_data)
  
          unset_first_value = (
              128.0 / 255.0 if colormap_mode.startswith("V") else 0.0
          )
          unset_last_value = (
              134.0 / 255.0 if colormap_mode.startswith("V") else 1.0
          )
          if (
              color_scale is None or color_scale == 255
          ) and colormap_mode.startswith("V"):
              unset_first_value *= 255
              unset_last_value *= 255
          if "min_value" in extra_kwargs:
              unset_first_value = extra_kwargs["min_value"]
              unset_last_value = extra_kwargs["max_value"]
  
          first_color = [1.0, 0.0, 0.0]
          if colormap_mode == "VRGBA":
              first_color = [128.0 / 255.0] + first_color
  
          kwargs1 = {"filename": cmap_filename}
          kwargs1.update(extra_kwargs)
          if color_scale is not None:
              kwargs1["color_scale"] = color_scale
  
          cmap = create_colormap(kwargs1)
          assert cmap.colors.shape[0] == 4
          np.testing.assert_equal(cmap.colors[0], first_color)
          assert cmap.values.shape[0] == 4
          assert cmap.values[0] == unset_first_value
          assert cmap.values[-1] == unset_last_value
  
imports: import contextlib
  import os
  from tempfile import NamedTemporaryFile
  from unittest import mock
  import dask.array
  import numpy
  import pytest
  import xarray
  from satpy.enhancements import create_colormap, on_dask_array, on_separate_bands, using_map_blocks
label_desc: Use image node_id 1 for calling the TestColormapLoading obj's underlying member method code with example usage: obj.test_cmap_from_file(color_scale, colormap_mode, extra_kwargs, filename_suffix) without return types