# Path: moonlight/util/segments.py
# class SegmentsMode(enum.Enum):
#   STARTS = 1
#   CENTERS = 2
# def true_segments_1d(segments,
#                      mode=SegmentsMode.CENTERS,
#                      max_gap=0,
#                      min_length=0,
#                      name=None):
# def _segments_1d(values, mode, name=None):
#     def do_segments(values):
#     def empty_segments():
# def peaks(values, minval=None, invalidate_distance=0, name=None):
#     def loop_condition(_, current_peaks):
#     def loop_body(accepted_peaks, current_peaks):


from absl.testing import absltest
from moonlight.util import segments
import numpy as np
import tensorflow as tf
    with self.test_session():
      self.assertAllEqual(expected_centers, centers.eval())
      self.assertAllEqual(expected_lengths, lengths.eval())

  def test_peaks(self):
    values = tf.constant([5, 3, 1, 1, 0, 1, 2, 3, 3, 3, 2, 3, 4, 1, 2])
    with self.test_session():
      self.assertAllEqual(segments.peaks(values).eval(), [0, 8, 12, 14])
      self.assertAllEqual(segments.peaks(values, minval=3).eval(), [0, 8, 12])

  def test_peaks_empty(self):
    with self.test_session():
      self.assertAllEqual(segments.peaks([]).eval(), [])

  def test_peaks_invalidate_distance(self):
    values = tf.constant([0, 0, 10, 0, 5, 3, 2, 1, 2, 3, 8, 8, 7, 8])
    with self.test_session():
      self.assertAllEqual(
          segments.peaks(values, invalidate_distance=0).eval(), [2, 4, 10, 13])
      self.assertAllEqual(
          segments.peaks(values, invalidate_distance=1).eval(), [2, 4, 10, 13])
      self.assertAllEqual(
          segments.peaks(values, invalidate_distance=2).eval(), [2, 10, 13])
      self.assertAllEqual(
          segments.peaks(values, invalidate_distance=3).eval(), [2, 10])
      self.assertAllEqual(
          segments.peaks(values, invalidate_distance=4).eval(), [2, 10])
      self.assertAllEqual(
          segments.peaks(values, invalidate_distance=7).eval(), [2, 10])
      self.assertAllEqual(

# Path: moonlight/util/segments.py
# class SegmentsMode(enum.Enum):
#   STARTS = 1
#   CENTERS = 2
# def true_segments_1d(segments,
#                      mode=SegmentsMode.CENTERS,
#                      max_gap=0,
#                      min_length=0,
#                      name=None):
# def _segments_1d(values, mode, name=None):
#     def do_segments(values):
#     def empty_segments():
# def peaks(values, minval=None, invalidate_distance=0, name=None):
#     def loop_condition(_, current_peaks):
#     def loop_body(accepted_peaks, current_peaks):


# Path: moonlight/util/segments_test.py
from absl.testing import absltest
from moonlight.util import segments
import numpy as np
import tensorflow as tf

    with self.test_session():
      self.assertAllEqual(expected_centers, centers.eval())
      self.assertAllEqual(expected_lengths, lengths.eval())

  def test_peaks(self):
    values = tf.constant([5, 3, 1, 1, 0, 1, 2, 3, 3, 3, 2, 3, 4, 1, 2])
    with self.test_session():
      self.assertAllEqual(segments.peaks(values).eval(), [0, 8, 12, 14])
      self.assertAllEqual(segments.peaks(values, minval=3).eval(), [0, 8, 12])

  def test_peaks_empty(self):
    with self.test_session():
      self.assertAllEqual(segments.peaks([]).eval(), [])

  def test_peaks_invalidate_distance(self):
    values = tf.constant([0, 0, 10, 0, 5, 3, 2, 1, 2, 3, 8, 8, 7, 8])
    with self.test_session():
      self.assertAllEqual(
          segments.peaks(values, invalidate_distance=0).eval(), [2, 4, 10, 13])
      self.assertAllEqual(
          segments.peaks(values, invalidate_distance=1).eval(), [2, 4, 10, 13])
      self.assertAllEqual(
          segments.peaks(values, invalidate_distance=2).eval(), [2, 10, 13])
      self.assertAllEqual(
          segments.peaks(values, invalidate_distance=3).eval(), [2, 10])
      self.assertAllEqual(
          segments.peaks(values, invalidate_distance=4).eval(), [2, 10])
      self.assertAllEqual(
          segments.peaks(values, invalidate_distance=7).eval(), [2, 10])
      self.assertAllEqual(

          segments.peaks(values, invalidate_distance=8).eval(), [2, 13])