code: def test_rgb_density():
      b = 0xFFFF0000
      data = np.full((4, 4), b, dtype="uint32")
      assert tf._rgb_density(data) == 1.0
      data = np.zeros((4, 4), dtype="uint32")
      assert tf._rgb_density(data) == np.inf
      data[3, 3] = b
      assert tf._rgb_density(data) == 0
      data[2, 0] = data[0, 2] = data[1, 1] = b
      assert np.allclose(tf._rgb_density(data), 0.75)
      assert np.allclose(tf._rgb_density(data, 3), 1)
  
imports: from __future__ import annotations
  from io import BytesIO
  import numpy
  import xarray
  import dask.array
  import PIL
  import pytest
  import datashader.transfer_functions
  from datashader.tests.test_pandas import assert_eq_ndarray, assert_eq_xr, assert_image_close
label_desc: Use image node_id 27 for calling a global function with example usage: test_rgb_density() without return types