code: def convert_angles(angles, low=0, high=360, positive=False):
      """Element-wise conversion of arbitrary-unit circular quantities
      to radians.
  
      .. versionadded:: 0.3.4
  
      Parameters
      ----------
      angles : array_like
          Circular data.
      low : float or int, optional
          Low boundary for ``angles`` range.  Default is 0.
      high : float or int, optional
          High boundary for ``angles`` range.  Default is 360
          (for degrees to radians conversion).
      positive : boolean
          If True, radians are mapped on the :math:`[0, 2\\pi]`. Otherwise,
          the resulting angles are mapped from :math:`[-\\pi, \\pi)` (default).
  
      Returns
      -------
      radians : array_like
          Circular data in radians.
  
      Notes
      -----
      The formula to convert a set of angles :math:`\\alpha` from an arbitrary
      range :math:`[\\text{high},\\text{low}]` to radians
      :math:`[0, 2\\pi]` is:
  
      .. math::
  
          \\alpha_r = \\frac{2\\pi\\alpha}{\\text{high} - \\text{low}}
  
      If ``positive=False`` (default), the resulting angles in
      radians :math:`\\alpha_r` are then wrapped to the :math:`[-\\pi, \\pi)`
      range:
  
      .. math::
  
          (\\text{angle} + \\pi) \\mod 2 \\pi - \\pi
  
      Examples
      --------
      1. Convert degrees to radians
  
      >>> from pingouin import convert_angles
      >>> a = [0, 360, 180, 90, 45, 270]
      >>> convert_angles(a, low=0, high=360)
      array([ 0.        ,  0.        , -3.14159265,  1.57079633,  0.78539816,
             -1.57079633])
  
      with ``positive=True``:
  
      >>> convert_angles(a, low=0, high=360, positive=True)
      array([0.        , 6.28318531, 3.14159265, 1.57079633, 0.78539816,
             4.71238898])
  
      2. Convert hours (24h-format) to radians
  
      >>> sleep_onset = [22.5, 23.25, 24, 0.5, 1]
      >>> convert_angles(sleep_onset, low=0, high=24)
      array([-0.39269908, -0.19634954,  0.        ,  0.13089969,  0.26179939])
  
      3. Convert radians from :math:`[0, 2\\pi]` to :math:`[-\\pi, \\pi)`:
  
      >>> import numpy as np
      >>> rad = [0.1, 3.14, 5, 2, 6]
      >>> convert_angles(rad, low=0, high=2*np.pi)
      array([ 0.1       ,  3.14      , -1.28318531,  2.        , -0.28318531])
  
      4. Convert degrees from a 2-D array
  
      >>> np.random.seed(123)
      >>> deg = np.random.randint(low=0, high=360, size=(3, 4))
      >>> convert_angles(deg)
      array([[-0.66322512,  1.71042267, -2.26892803,  0.29670597],
             [ 1.44862328,  1.85004901,  2.14675498,  0.99483767],
             [-2.54818071, -2.35619449,  1.67551608,  1.97222205]])
      """
      assert isinstance(positive, bool)
      assert isinstance(high, (int, float)), "high must be numeric"
      assert isinstance(low, (int, float)), "low must be numeric"
      ptp = high - low
      assert ptp > 0, "high - low must be strictly positive."
      angles = np.asarray(angles)
      assert np.nanmin(angles) >= low, "angles cannot be >= low."
      assert np.nanmax(angles) <= high, "angles cannot be <= high."
      # Map to [0, 2pi] range
      rad = angles * (2 * np.pi) / ptp
      if not positive:
          # https://stackoverflow.com/a/29237626/10581531
          # Map to [-pi, pi) range:
          rad = (rad + np.pi) % (2 * np.pi) - np.pi  # [-pi, pi)
          # Map to (-pi, pi] range:
          # rad = np.angle(np.exp(1j * rad))
          # rad = -1 * ((-rad + np.pi) % (2 * np.pi) - np.pi)
      return rad
  
file_path: pingouin/pingouin/circular.py
imports: import numpy
  from scipy.stats import norm
  from .utils import remove_na
label_desc: Use image node_id 2 for calling a global function with example usage: convert_angles(angles, low, high, positive) and returns: rad