code: def test_hog_basic_orientations_and_data_types():
      # scenario:
      #  1) create image (with float values) where upper half is filled by
      #     zeros, bottom half by 100
      #  2) create unsigned integer version of this image
      #  3) calculate feature.hog() for both images, both with 'transform_sqrt'
      #     option enabled and disabled
      #  4) verify that all results are equal where expected
      #  5) verify that computed feature vector is as expected
      #  6) repeat the scenario for 90, 180 and 270 degrees rotated images
  
      # size of testing image
      width = height = 35
  
      image0 = np.zeros((height, width), dtype="float")
      image0[height // 2 :] = 100
  
      for rot in range(4):
          # rotate by 0, 90, 180 and 270 degrees
          image_float = np.rot90(image0, rot)
  
          # create uint8 image from image_float
          image_uint8 = image_float.astype("uint8")
  
          (hog_float, hog_img_float) = feature.hog(
              image_float,
              orientations=4,
              pixels_per_cell=(8, 8),
              cells_per_block=(1, 1),
              visualize=True,
              transform_sqrt=False,
              block_norm="L1",
          )
          (hog_uint8, hog_img_uint8) = feature.hog(
              image_uint8,
              orientations=4,
              pixels_per_cell=(8, 8),
              cells_per_block=(1, 1),
              visualize=True,
              transform_sqrt=False,
              block_norm="L1",
          )
          (hog_float_norm, hog_img_float_norm) = feature.hog(
              image_float,
              orientations=4,
              pixels_per_cell=(8, 8),
              cells_per_block=(1, 1),
              visualize=True,
              transform_sqrt=True,
              block_norm="L1",
          )
          (hog_uint8_norm, hog_img_uint8_norm) = feature.hog(
              image_uint8,
              orientations=4,
              pixels_per_cell=(8, 8),
              cells_per_block=(1, 1),
              visualize=True,
              transform_sqrt=True,
              block_norm="L1",
          )
  
          # set to True to enable manual debugging with graphical output,
          # must be False for automatic testing
          if False:
              import matplotlib.pyplot as plt
  
              plt.figure()
              plt.subplot(2, 3, 1)
              plt.imshow(image_float)
              plt.colorbar()
              plt.title("image")
              plt.subplot(2, 3, 2)
              plt.imshow(hog_img_float)
              plt.colorbar()
              plt.title("HOG result visualisation (float img)")
              plt.subplot(2, 3, 5)
              plt.imshow(hog_img_uint8)
              plt.colorbar()
              plt.title("HOG result visualisation (uint8 img)")
              plt.subplot(2, 3, 3)
              plt.imshow(hog_img_float_norm)
              plt.colorbar()
              plt.title(
                  "HOG result (transform_sqrt) visualisation (float img)"
              )
              plt.subplot(2, 3, 6)
              plt.imshow(hog_img_uint8_norm)
              plt.colorbar()
              plt.title(
                  "HOG result (transform_sqrt) visualisation (uint8 img)"
              )
              plt.show()
  
          # results (features and visualisation) for float and uint8 images must
          # be almost equal
          assert_almost_equal(hog_float, hog_uint8)
          assert_almost_equal(hog_img_float, hog_img_uint8)
  
          # resulting features should be almost equal
          # when 'transform_sqrt' is enabled
          # or disabled (for current simple testing image)
          assert_almost_equal(hog_float, hog_float_norm, decimal=4)
          assert_almost_equal(hog_float, hog_uint8_norm, decimal=4)
  
          # reshape resulting feature vector to matrix with 4 columns (each
          # corresponding to one of 4 directions); only one direction should
          # contain nonzero values (this is manually determined for testing
          # image)
          actual = np.max(hog_float.reshape(-1, 4), axis=0)
  
          if rot in [0, 2]:
              # image is rotated by 0 and 180 degrees
              desired = [0, 0, 1, 0]
          elif rot in [1, 3]:
              # image is rotated by 90 and 270 degrees
              desired = [1, 0, 0, 0]
          else:
              raise Exception(
                  "Result is not determined for this rotation."
              )
  
          assert_almost_equal(actual, desired, decimal=2)
  
file_path: scikit-image/skimage/feature/tests/test_hog.py
imports: import numpy
  import pytest
  from numpy.testing import assert_almost_equal
  from skimage import color, data, draw, feature, img_as_float
  from skimage._shared import filters
  from skimage._shared.testing import fetch
  from skimage._shared.utils import _supported_float_type
label_desc: Use image node_id 6 for calling a global function with example usage: test_hog_basic_orientations_and_data_types() without return types