def test_apply_weights_bound(self):
        test_bunch = Bunch()
        for i in range(1000):
            x = random.gauss(0., 10.**0.5)
            y = random.gauss(0., 20.**0.5)
            test_hit = Hit.new_from_dict({'x':x, 'y':y})
            test_bunch.append(test_hit)
        limit_ellipse = numpy.zeros([2, 2])
        for i in range(2):
            limit_ellipse[i, i] = 200.
        bound = BoundingEllipse(limit_ellipse, numpy.zeros([2]), 50)

        my_weights = VoronoiWeighting(['x', 'y'],
                                      numpy.array([[20., 0.],[0., 20.]]),
                                      voronoi_bound = bound)
        print("Plotting weights", datetime.datetime.now())
        canvas, hist = test_bunch.root_histogram('x', 'mm', 'y', 'mm')
        hist.Draw("COLZ")
        canvas.Update()
        print('Covariances ["x", "y"] before\n', test_bunch.covariance_matrix(['x', 'y']))
        print("Applying weights", datetime.datetime.now())
        my_weights.apply_weights(test_bunch, False)
        print("Plotting tesselation", datetime.datetime.now())
        #my_weights.plot_two_d_projection(['x', 'y'], 'weight')
        my_weights.plot_two_d_projection(['x', 'y'], 'weight')
        my_weights.plot_two_d_projection(['x', 'y'], 'content')
        print("Plotting weights", datetime.datetime.now())
        canvas, hist = test_bunch.root_histogram('x', 'mm', 'y', 'mm')
        hist.Draw("COLZ")
        canvas.Update()
        test_bunch.root_histogram('local_weight', nx_bins=100)
        canvas = common.make_root_canvas('local_weight')
        hist = common.make_root_histogram('local_weight', test_bunch.list_get_hit_variable(['local_weight'])[0], 'local_weight', 100)
        hist.Draw()
        canvas.Update()
        canvas = common.make_root_canvas('content')
        hist = common.make_root_histogram('content', my_weights.tile_content_list, 'content', 100)
        hist.Draw()
        canvas.Update()
        print('Covariances ["x", "y"] after\n', test_bunch.covariance_matrix(['x', 'y']))