def test_quadratic_expand(self): i = [[0, 1, 2]] e = [[0], [1], [2]] o = quadratic_expand(i) self.assertEqual(e, o) i = [[0, 1, 2], [3, 4, 5]] e = [[0, 3], [1, 3], [2, 3], [0, 4], [1, 4], [2, 4], [0, 5], [1, 5], [2, 5]] o = quadratic_expand(i) self.assertEqual(e, o)
def test_sampleHolesUniformly(self): ncols = 1144 nrows = 1024 bounds = [(64, ncols), (64, nrows)] expected = [xy_to_hn(x, y) for x,y in sampleUniformly(100, bounds)] all_xy = quadratic_expand([range(64, ncols), range(64, nrows)]) all_holes = [xy_to_hn(x, y) for x, y in all_xy] samples = sampleHolesUniformly(100, all_holes) self.assertEqual(expected, samples)