code: def square(t, duty=0.5):
      """
      Return a periodic square-wave waveform.
  
      The square wave has a period ``2*pi``, has value +1 from 0 to
      ``2*pi*duty`` and -1 from ``2*pi*duty`` to ``2*pi``. `duty` 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
          The input time array.
      duty : array_like, optional
          Duty cycle.  Default is 0.5 (50% duty cycle).
          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 square waveform.
  
      Examples
      --------
      A 5 Hz waveform sampled at 500 Hz for 1 second:
  
      >>> import cupyx.scipy.signal
      >>> import cupy as cp
      >>> import matplotlib.pyplot as plt
      >>> t = cupy.linspace(0, 1, 500, endpoint=False)
      >>> plt.plot(cupy.asnumpy(t), cupy.asnumpy(cupyx.scipy.signal.square(2 * cupy.pi * 5 * t)))
      >>> plt.ylim(-2, 2)
  
      A pulse-width modulated sine wave:
  
      >>> plt.figure()
      >>> sig = cupy.sin(2 * cupy.pi * t)
      >>> pwm = cupyx.scipy.signal.square(2 * cupy.pi * 30 * t, duty=(sig + 1)/2)
      >>> plt.subplot(2, 1, 1)
      >>> plt.plot(cupy.asnumpy(t), cupy.asnumpy(sig))
      >>> plt.subplot(2, 1, 2)
      >>> plt.plot(cupy.asnumpy(t), cupy.asnumpy(pwm))
      >>> plt.ylim(-1.5, 1.5)
  
      """  # NOQA
      t, w = cupy.asarray(t), cupy.asarray(duty)
      y = _square_kernel(t, w)
      return y
  
file_path: cupy/cupyx/scipy/signal/_waveforms.py
imports: import cupy
  from cupy._core._scalar import get_typename
  from cupy_backends.cuda.api import runtime
  import numpy
label_desc: Use image node_id 4 for calling a global function with example usage: square(t, duty) and returns: y