code: def test_remap_boxes():
      pred = geometry.remap_boxes(
          np.asarray(
              [[[0.25, 0.25], [0.25, 0.75], [0.75, 0.25], [0.75, 0.75]]]
          ),
          (10, 10),
          (20, 20),
      )
      target = np.asarray(
          [
              [
                  [0.375, 0.375],
                  [0.375, 0.625],
                  [0.625, 0.375],
                  [0.625, 0.625],
              ]
          ]
      )
      assert np.all(pred == target)
  
      pred = geometry.remap_boxes(
          np.asarray(
              [[[0.25, 0.25], [0.25, 0.75], [0.75, 0.25], [0.75, 0.75]]]
          ),
          (10, 10),
          (20, 10),
      )
      target = np.asarray(
          [[[0.25, 0.375], [0.25, 0.625], [0.75, 0.375], [0.75, 0.625]]]
      )
      assert np.all(pred == target)
  
      with pytest.raises(ValueError):
          geometry.remap_boxes(
              np.asarray(
                  [
                      [
                          [0.25, 0.25],
                          [0.25, 0.75],
                          [0.75, 0.25],
                          [0.75, 0.75],
                      ]
                  ]
              ),
              (80, 40, 150),
              (160, 40),
          )
  
      with pytest.raises(ValueError):
          geometry.remap_boxes(
              np.asarray(
                  [
                      [
                          [0.25, 0.25],
                          [0.25, 0.75],
                          [0.75, 0.25],
                          [0.75, 0.75],
                      ]
                  ]
              ),
              (80, 40),
              (160,),
          )
  
      orig_dimension = (100, 100)
      dest_dimensions = (200, 100)
      # Unpack dimensions
      height_o, width_o = orig_dimension
      height_d, width_d = dest_dimensions
  
      orig_box = np.asarray(
          [[[0.25, 0.25], [0.25, 0.25], [0.75, 0.75], [0.75, 0.75]]]
      )
  
      pred = geometry.remap_boxes(
          orig_box, orig_dimension, dest_dimensions
      )
  
      # Switch to absolute coords
      orig = np.stack(
          (orig_box[:, :, 0] * width_o, orig_box[:, :, 1] * height_o),
          axis=2,
      )[0]
      dest = np.stack(
          (pred[:, :, 0] * width_d, pred[:, :, 1] * height_d), axis=2
      )[0]
  
      len_orig = hypot(orig[0][0] - orig[2][0], orig[0][1] - orig[2][1])
      len_dest = hypot(dest[0][0] - dest[2][0], dest[0][1] - dest[2][1])
      assert len_orig == len_dest
  
      alpha_orig = np.rad2deg(
          np.arctan(
              (orig[0][1] - orig[2][1]) / (orig[0][0] - orig[2][0])
          )
      )
      alpha_dest = np.rad2deg(
          np.arctan(
              (dest[0][1] - dest[2][1]) / (dest[0][0] - dest[2][0])
          )
      )
      assert alpha_orig == alpha_dest
  
file_path: doctr/tests/common/test_utils_geometry.py
imports: from copy import deepcopy
  from math import hypot
  import numpy
  import pytest
  from doctr.io import DocumentFile
  from doctr.utils import geometry
label_desc: Use image node_id 5 for calling a global function with example usage: test_remap_boxes() without return types