class_docstr: A basic step function
  
  Values at the ends are handled in the simplest way possible: everything to
  the left of ``x[0]`` is set to `ival`; everything to the right of ``x[-1]``
  is set to ``y[-1]``.
  
  Examples
  --------
  >>> x = np.arange(20)
  >>> y = np.arange(20)
  >>> f = StepFunction(x, y)
  >>>
  >>> f(3.2)
  3.0
  >>> res = f([[3.2, 4.5],[24, -3.1]])
  >>> np.all(res == [[ 3, 4],
  ...                [19, 0]])
  True
code: def __init__(self, x, y, ival=0.0, sorted=False):
      _x = np.asarray(x)
      _y = np.asarray(y)
  
      if _x.shape != _y.shape:
          raise ValueError(
              "in StepFunction: x and y do not have the same shape"
          )
      if len(_x.shape) != 1:
          raise ValueError(
              "in StepFunction: x and y must be 1-dimensional"
          )
  
      self.x = np.hstack([[-np.inf], _x])
      self.y = np.hstack([[ival], _y])
  
      if not sorted:
          asort = np.argsort(self.x)
          self.x = np.take(self.x, asort, 0)
          self.y = np.take(self.y, asort, 0)
      self.n = self.x.shape[0]
  
file_path: nipy/nipy/algorithms/statistics/models/utils.py
imports: import numpy
  import scipy.interpolate
label_desc: Use image node_id 1 to create a new StepFunction object  with example: obj = StepFunction(x, y, ival, sorted)