Exemplo n.º 1
0
    def test_change_zoom_level_smaller_manual_check(self):
        add_stochastic_noise(1, self.dim, self.arr)
        cy.clear_bounds(self.dim, self.arr)
        self.arr[0, 0] = 2  # make the zoomer resize
        dim, buf, change, self.buf_stat = change_zoom_level(
            self.position, self.buf_len, self.buf_stat, self.change_roll,
            self.dim, self.buf)
        nu_arr = buf[self.position[0]]
        self.assertEqual(nu_arr[1, 1], 2)
        self.assertEqual(change[0, 1], 1)
        nu_arr[1, 1] = 0
        nu_arr_mid = np.copy(nu_arr)
        nu_arr[0, 0] = 2  #zoom again

        dim, buf, change, self.buf_stat = change_zoom_level(
            self.position, self.buf_len, self.buf_stat, change, dim, buf)
        nu_arr = buf[self.position[0]]
        self.assertEqual(nu_arr[1, 1], 2)  #second assert
        self.assertEqual(change[0, 1], 1)
        nu_arr[1, 1] = 0

        dim, buf, change, self.buf_stat = change_zoom_level(
            self.position, self.buf_len, self.buf_stat, change, dim, buf)
        nu_arr = buf[self.position[0]]
        self.assertEqual(change[0, 1], -1)

        testing.assert_array_equal(nu_arr, nu_arr_mid)
Exemplo n.º 2
0
    def test_clear_bounds(self):
        arr = tst_arr()
        cy.clear_bounds(tst_dim(), arr)

        arr2 = tst_arr()
        arr2[0, :] = 0
        arr2[-1, :] = 0
        arr2[:, 0] = 0
        arr2[:, -1] = 0

        testing.assert_array_equal(arr2, arr)
Exemplo n.º 3
0
 def test_change_zoom_level_same(self):
     add_stochastic_noise(1, self.dim, self.arr)
     cy.clear_bounds(self.dim, self.arr)
     self.assertEqual(len(self.buf_stat), 1)
     dim, buf, change, self.buf_stat = change_zoom_level(
         self.position, self.buf_len, self.buf_stat, self.change_roll,
         self.dim, self.buf)
     self.assertEqual(change[0, 1], 0)
     self.assertEqual(dim[0], self.dim[0])
     testing.assert_array_equal(self.arr, buf[self.position[0]])
     self.assertEqual(len(self.buf_stat), 1)