code: def sawtooth(t, width=1):
      """
      Return a periodic sawtooth or triangle waveform.
  
      The sawtooth waveform has a period ``2*pi``, rises from -1 to 1 on the
      interval 0 to ``width*2*pi``, then drops from 1 to -1 on the interval
      ``width*2*pi`` to ``2*pi``. `width` must be in the interval [0, 1].
  
      Note that this is not band-limited.  It produces an infinite number
      of harmonics, which are aliased back and forth across the frequency
      spectrum.
  
      Parameters
      ----------
      t : array_like
          Time.
      width : array_like, optional
          Width of the rising ramp as a proportion of the total cycle.
          Default is 1, producing a rising ramp, while 0 produces a falling
          ramp.  `width` = 0.5 produces a triangle wave.
          If an array, causes wave shape to change over time, and must be the
          same length as t.
  
      Returns
      -------
      y : ndarray
          Output array containing the sawtooth waveform.
  
      Examples
      --------
      A 5 Hz waveform sampled at 500 Hz for 1 second:
  
      >>> from scipy import signal
      >>> import matplotlib.pyplot as plt
      >>> t = np.linspace(0, 1, 500)
      >>> plt.plot(t, signal.sawtooth(2 * np.pi * 5 * t))
  
      """
      t, w = asarray(t), asarray(width)
      w = asarray(w + (t - t))
      t = asarray(t + (w - w))
      if t.dtype.char in ["fFdD"]:
          ytype = t.dtype.char
      else:
          ytype = "d"
      y = zeros(t.shape, ytype)
  
      # width must be between 0 and 1 inclusive
      mask1 = (w > 1) | (w < 0)
      place(y, mask1, nan)
  
      # take t modulo 2*pi
      tmod = mod(t, 2 * pi)
  
      # on the interval 0 to width*2*pi function is
      #  tmod / (pi*w) - 1
      mask2 = (1 - mask1) & (tmod < w * 2 * pi)
      tsub = extract(mask2, tmod)
      wsub = extract(mask2, w)
      place(y, mask2, tsub / (pi * wsub) - 1)
  
      # on the interval width*2*pi to 2*pi function is
      #  (pi*(w+1)-tmod) / (pi*(1-w))
  
      mask3 = (1 - mask1) & (1 - mask2)
      tsub = extract(mask3, tmod)
      wsub = extract(mask3, w)
      place(y, mask3, (pi * (wsub + 1) - tsub) / (pi * (1 - wsub)))
      return y
  
file_path: catboost/contrib/python/scipy/py3/scipy/signal/waveforms.py
imports: import numpy
  from numpy import asarray, zeros, place, nan, mod, pi, extract, log, sqrt, exp, cos, sin, polyval, polyint
label_desc: Use image node_id 1 for calling a global function with example usage: sawtooth(t, width) and returns: y