def _data()

in moonlight/staves/hough.py [0:0]


  def _data(self):

    def detection_loop_body(i, staves, staffline_distances):
      """Per-staffline-distance staff detection loop.

      Args:
        i: The index of the current staffline distance to use.
        staves: The current staves tensor of shape (N, 2, 2).
        staffline_distances: The current staffline distance tensor. 1D with
          length N.

      Returns:
        i + 1.
        staves concatd with any newly detected staves.
        staffline_distance with the current staffline distance appended for each
            new staff.
      """
      current_staffline_distance = self.estimated_staffline_distance[i]
      current_staves = _SingleSizeFilteredHoughStaffDetector(
          self.image, current_staffline_distance,
          self.estimated_staffline_thickness, self.max_abs_theta,
          self.num_theta).staves
      staves = tf.concat([staves, current_staves], axis=0)
      staffline_distances = tf.concat([
          staffline_distances,
          tf.tile([current_staffline_distance],
                  tf.shape(staves)[0:1]),
      ],
                                      axis=0)
      return i + 1, staves, staffline_distances

    num_staffline_distances = tf.shape(self.estimated_staffline_distance)[0]
    _, staves, staffline_distances = tf.while_loop(
        lambda i, _, __: tf.less(i, num_staffline_distances),
        detection_loop_body, [
            tf.constant(0),
            tf.zeros([0, 2, 2], tf.int32),
            tf.zeros([0], tf.int32)
        ],
        shape_invariants=[
            tf.TensorShape(()),
            tf.TensorShape([None, 2, 2]),
            tf.TensorShape([None])
        ],
        parallel_iterations=1)

    # Sort by y0.
    order, = _argsort(staves[:, 0, 1])
    staves = tf.gather(staves, order)
    staffline_distances = tf.gather(staffline_distances, order)

    return staves, staffline_distances