message: Added an additional check on the length of the values and boundaries lists.
diff: @@ -130,8 +130,12 @@ def piecewise_constant(x, boundaries, values, name=None):
  Raises:
  ValueError: if types of `x` and `boundaries` do not match, or types of all
  - `values` do not match.
  + `values` do not match or
  + the number of elements in the lists does not match.
  """
  + if len(boundaries) != len(values) - 1:
  + raise ValueError(
  + "The length of boundaries should be 1 less than the length of values")
  with ops.name_scope(name, "PiecewiseConstant",
  [x, boundaries, values, name]) as name:
  x = ops.convert_to_tensor(x)
  @@ -158,7 +162,6 @@ def piecewise_constant(x, boundaries, values, name=None):
  raise ValueError(
  "Values must have elements all with the same dtype (%s vs %s)." % (
  values[0].dtype.base_dtype, v.dtype.base_dtype))
  -
  pred_fn_pairs = {}
  pred_fn_pairs[x <= boundaries[0]] = lambda: values[0]
  pred_fn_pairs[x > boundaries[-1]] = lambda: values[-1]
  