docs: def mag(val, u=Ellipsis):
      '''
      mag(scalar) yields scalar for the given scalar (numeric value without a unit).
      mag(quant) yields the scalar magnitude of the quantity quant.
      mag(scalar, u=u) yields scalar.
      mag(quant, u=u) yields the given magnitude of the given quant after being translated into the
        given unit u.
  
      The quant arguments in the above list may be replaced with (scalar, unit) as in (10, 'degrees')
      or (14, 'mm'). Note that mag always translates all lists and tuples into numpy ndarrays.
      '''
      if not is_quantity(val): return val
      if isinstance(val, tuple):
          val = units.Quantity(val[0], val[1])
      return val.m if u is Ellipsis else val.to(unit(u)).m