Exemplo n.º 1
0
    def test_zero_extra_entries(self, its=100):
        """Checks zero_extra_entries against its equivalent definition."""
        for it in range(its):
            l = random.choice([0, 1, randint(0, 10)])
            u = random.choice([0, 1, randint(0, 10)])
            size = random.choice([0, 1, randint(0, 10), randint(0, 100)])
            mat_rect = randn(l + u + 1, size)
            mat_rect_good = mat_rect.copy()
            array_mem = get_array_mem(mat_rect)

            fl.zero_extra_entries(l, u, mat_rect)
            mat_rect_good[:] = fl.band_e(l, u, fl.band_c(l, u, mat_rect_good))
            assert_allequal(mat_rect, mat_rect_good)
            assert get_array_mem(mat_rect) == array_mem
Exemplo n.º 2
0
    def test_zero_extra_entries(self, its=100):
        """Checks zero_extra_entries against its equivalent definition."""
        for it in range(its):
            l = random.choice([0, 1, randint(0, 10)])
            u = random.choice([0, 1, randint(0, 10)])
            size = random.choice([0, 1, randint(0, 10), randint(0, 100)])
            mat_rect = randn(l + u + 1, size)
            mat_rect_good = mat_rect.copy()
            array_mem = get_array_mem(mat_rect)

            fl.zero_extra_entries(l, u, mat_rect)
            mat_rect_good[:] = fl.band_e(l, u, fl.band_c(l, u, mat_rect_good))
            assert_allequal(mat_rect, mat_rect_good)
            assert get_array_mem(mat_rect) == array_mem
Exemplo n.º 3
0
    def test_randomize_extra_entries(self, its=50):
        for it in range(its):
            size = random.choice([0, 1, randint(0, 10), randint(0, 100)])
            l = random.choice([0, 1, randint(0, 10)])
            u = random.choice([0, 1, randint(0, 10)])

            mat_rect = randn(l + u + 1, size)
            assert np.all(mat_rect != 0.0)
            fl.zero_extra_entries(l, u, mat_rect)
            th.randomize_extra_entries(l, u, mat_rect)
            assert np.all(mat_rect != 0.0)

            mat_rect = np.zeros((l + u + 1, size))
            assert np.all(mat_rect == 0.0)
            th.randomize_extra_entries(l, u, mat_rect)
            fl.zero_extra_entries(l, u, mat_rect)
            assert np.all(mat_rect == 0.0)