code: def test_rgb_spread():
      p = 0x7D00007D
      g = 0x7D00FF00
      b = 0x7DFF0000
      data = np.array(
          [
              [p, p, 0, 0, 0],
              [p, g, 0, 0, 0],
              [0, 0, 0, 0, 0],
              [0, 0, 0, b, 0],
              [0, 0, 0, 0, 0],
          ],
          dtype="uint32",
      )
      coords = [np.arange(5), np.arange(5)]
      img = tf.Image(data, coords=coords, dims=dims)
  
      s = tf.spread(img)
      o = np.array(
          [
              [
                  0xED00863B,
                  0xED00863B,
                  0xBC00A82A,
                  0x00000000,
                  0x00000000,
              ],
              [
                  0xED00863B,
                  0xED00863B,
                  0xBC00A82A,
                  0x00000000,
                  0x00000000,
              ],
              [
                  0xBC00A82A,
                  0xBC00A82A,
                  0xBCA85600,
                  0x7DFF0000,
                  0x7DFF0000,
              ],
              [
                  0x00000000,
                  0x00000000,
                  0x7DFF0000,
                  0x7DFF0000,
                  0x7DFF0000,
              ],
              [
                  0x00000000,
                  0x00000000,
                  0x7DFF0000,
                  0x7DFF0000,
                  0x7DFF0000,
              ],
          ]
      )
      np.testing.assert_equal(s.data, o)
      assert (s.x_axis == img.x_axis).all()
      assert (s.y_axis == img.y_axis).all()
      assert s.dims == img.dims
  
      s = tf.spread(img, px=2)
      o = np.array(
          [
              [
                  0xED00863B,
                  0xED00863B,
                  0xED00863B,
                  0xBC00A82A,
                  0x00000000,
              ],
              [
                  0xED00863B,
                  0xED00863B,
                  0xF581411C,
                  0xDC904812,
                  0x7DFF0000,
              ],
              [
                  0xED00863B,
                  0xF581411C,
                  0xED864419,
                  0xBCA85600,
                  0x7DFF0000,
              ],
              [
                  0xBC00A82A,
                  0xDC904812,
                  0xBCA85600,
                  0x7DFF0000,
                  0x7DFF0000,
              ],
              [
                  0x00000000,
                  0x7DFF0000,
                  0x7DFF0000,
                  0x7DFF0000,
                  0x7DFF0000,
              ],
          ]
      )
      np.testing.assert_equal(s.data, o)
  
      s = tf.spread(img, shape="square")
      o = np.array(
          [
              [
                  0xED00863B,
                  0xED00863B,
                  0xBC00A82A,
                  0x00000000,
                  0x00000000,
              ],
              [
                  0xED00863B,
                  0xED00863B,
                  0xBC00A82A,
                  0x00000000,
                  0x00000000,
              ],
              [
                  0xBC00A82A,
                  0xBC00A82A,
                  0xBCA85600,
                  0x7DFF0000,
                  0x7DFF0000,
              ],
              [
                  0x00000000,
                  0x00000000,
                  0x7DFF0000,
                  0x7DFF0000,
                  0x7DFF0000,
              ],
              [
                  0x00000000,
                  0x00000000,
                  0x7DFF0000,
                  0x7DFF0000,
                  0x7DFF0000,
              ],
          ]
      )
      np.testing.assert_equal(s.data, o)
  
      s = tf.spread(img, how="add")
      o = np.array(
          [
              [
                  0xFF007DB7,
                  0xFF007DB7,
                  0xFA007F3E,
                  0x00000000,
                  0x00000000,
              ],
              [
                  0xFF007DB7,
                  0xFF007DB7,
                  0xFA007F3E,
                  0x00000000,
                  0x00000000,
              ],
              [
                  0xFA007F3E,
                  0xFA007F3E,
                  0xFA7F7F00,
                  0x7DFF0000,
                  0x7DFF0000,
              ],
              [
                  0x00000000,
                  0x00000000,
                  0x7DFF0000,
                  0x7DFF0000,
                  0x7DFF0000,
              ],
              [
                  0x00000000,
                  0x00000000,
                  0x7DFF0000,
                  0x7DFF0000,
                  0x7DFF0000,
              ],
          ]
      )
      np.testing.assert_equal(s.data, o)
  
      mask = np.array([[1, 0, 1], [0, 1, 0], [1, 0, 1]])
      s = tf.spread(img, mask=mask)
      o = np.array(
          [
              [
                  0xBC00A82A,
                  0xBC00007D,
                  0x7D00FF00,
                  0x00000000,
                  0x00000000,
              ],
              [
                  0xBC00007D,
                  0xBC00A82A,
                  0x7D00007D,
                  0x00000000,
                  0x00000000,
              ],
              [
                  0x7D00FF00,
                  0x7D00007D,
                  0xBCA85600,
                  0x00000000,
                  0x7DFF0000,
              ],
              [
                  0x00000000,
                  0x00000000,
                  0x00000000,
                  0x7DFF0000,
                  0x00000000,
              ],
              [
                  0x00000000,
                  0x00000000,
                  0x7DFF0000,
                  0x00000000,
                  0x7DFF0000,
              ],
          ]
      )
      np.testing.assert_equal(s.data, o)
  
      s = tf.spread(img, px=0)
      np.testing.assert_equal(s.data, img.data)
  
      pytest.raises(ValueError, lambda: tf.spread(img, px=-1))
      pytest.raises(ValueError, lambda: tf.spread(img, mask=np.ones(2)))
      pytest.raises(
          ValueError, lambda: tf.spread(img, mask=np.ones((2, 2)))
      )
  
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 22 for calling a global function with example usage: test_rgb_spread() without return types