Beispiel #1
0
    def test_bout_num1(self):
        """Assures that Behavior.bout_num() works with bouts."""
        behav1 = behavior.Behavior('b1', 10, [5], [10])
        self.assertEqual(behav1.bout_num(), 1)

        behav2 = behavior.Behavior('b2', 10, [2, 6, 8], [3, 7, 10])
        self.assertEqual(behav2.bout_num(), 3)
Beispiel #2
0
    def test_bout_durations1(self):
        """Assures that Behavior.bout_durations() works with bouts."""
        behav1 = behavior.Behavior('b1', 10, [5], [10])
        np.testing.assert_array_equal(behav1.bout_durations(), [5])

        behav2 = behavior.Behavior('b2', 10, [2, 6, 8], [3, 7, 10])
        np.testing.assert_array_equal(behav2.bout_durations(), [1, 1, 2])
Beispiel #3
0
    def test_index1(self):
        """Assures Behavior.index() `mode`s 'all' and 'condensed' works with
        bouts present."""
        behav1 = behavior.Behavior('b1', 100, [20, 80], [40, 100])
        self.assertEqual(behav1.index(mode='all'), 0.4)
        self.assertEqual(behav1.index(mode='condensed'), 0.5)

        behav2 = behavior.Behavior('b2', 10, [4, 8], [5, 10])
        self.assertEqual(behav2.index(mode='all'), 0.3)
        self.assertEqual(behav2.index(mode='condensed'), 0.5)

        behav3 = behavior.Behavior('b3', 10, [5], [10])
        self.assertEqual(behav3.index(mode='all'), 0.5)
        self.assertEqual(behav3.index(mode='condensed'), 1)
Beispiel #4
0
    def test_init1(self):
        """Assures attributes are set given an normal initialization."""
        behav1 = behavior.Behavior('behavior_1', 100, [50, 70], [60, 80])

        np.testing.assert_array_equal(behav1.start_ixs, np.array([50, 70]))
        np.testing.assert_array_equal(behav1.stop_ixs, np.array([60, 80]))
        self.assertEqual(behav1.name, 'behavior_1')
        self.assertEqual(behav1.length, 100)
Beispiel #5
0
    def test_ixs1(self):
        """Assures Behavior.ixs() returns expected array given start/stop
        indices upon initialization."""
        start_ixs = [20, 40, 60]
        stop_ixs = [30, 50, 70]
        behav = behavior.Behavior('behavior1', 100, start_ixs, stop_ixs)

        np.testing.assert_array_equal(behav.ixs(),
                                      np.array([start_ixs, stop_ixs]).T)
Beispiel #6
0
 def test_as_array2(self):
     """Assures Behavior.as_array() works with empty behavior."""
     behav = behavior.Behavior('b1', 100, [], [])
     np.testing.assert_array_equal(behav.as_array(), np.zeros(100))
Beispiel #7
0
 def test_as_array1(self):
     """Assures Behavior.as_array() works with non-empty behavior."""
     behav = behavior.Behavior('b1', 10, [2, 8], [4, 10])
     np.testing.assert_array_equal(behav.as_array(),
                                   [0, 0, 1, 1, 0, 0, 0, 0, 1, 1])
Beispiel #8
0
 def test_ixs2(self):
     """Assures Behavior.ixs() returns expected array given empty start/stop
     indices upon initialization."""
     behav = behavior.Behavior('b1', 100, [], [])
     self.assertEqual(behav.ixs().size, 0)
     np.testing.assert_array_equal(behav.ixs().shape, (0, 2))
Beispiel #9
0
 def test_init3(self):
     """Assures that start indices longer than `length` are truncated."""
     behav = behavior.Behavior('b1', 100, [50, 80, 120], [60, 100, 140])
     np.testing.assert_array_equal(behav.start_ixs, [50, 80])
     np.testing.assert_array_equal(behav.stop_ixs, [60, 100])
Beispiel #10
0
 def test_bout_durations2(self):
     """Assures that Behavior.bout_durations() works with no bouts."""
     behav1 = behavior.Behavior('b1', 10, [], [])
     np.testing.assert_array_equal(behav1.bout_durations(), [])
Beispiel #11
0
 def test_bout_num2(self):
     """Assures that Behavior.bout_num() works with no bouts."""
     behav1 = behavior.Behavior('b1', 10, [], [])
     self.assertEqual(behav1.bout_num(), 0)
Beispiel #12
0
 def test_latency2(self):
     """Assures that Behavior.latency() works with no bouts."""
     behav = behavior.Behavior('b', 10, [], [])
     self.assertEqual(behav.latency(), 10)
Beispiel #13
0
 def test_latency1(self):
     """Assures that Behavior.latency() works with bouts."""
     behav = behavior.Behavior('b', 10, [5], [10])
     self.assertEqual(behav.latency(), 5)
Beispiel #14
0
 def test_index2(self):
     """Assures Behavior.index() `mode`s 'all' and 'condensed' works with
     no bouts present."""
     behav = behavior.Behavior('b1', 10, [], [])
     self.assertEqual(behav.index(mode='all'), 0)
     self.assertEqual(behav.index(mode='condensed'), 0)