Ejemplo n.º 1
0
    def tst_consistent(self):
        from random import randint
        from dials.model.data import Shoebox
        from dials.array_family import flex

        for i in range(1000):

            x0 = randint(0, 1000)
            y0 = randint(0, 1000)
            z0 = randint(0, 1000)
            x1 = randint(1, 10) + x0
            y1 = randint(1, 10) + y0
            z1 = randint(1, 10) + z0
            try:
                shoebox = Shoebox((x0, x1, y0, y1, z0, z1))
                assert (not shoebox.is_consistent())
                shoebox.allocate()
                assert (shoebox.is_consistent())
                shoebox.data = flex.real(flex.grid(20, 20, 20))
                assert (not shoebox.is_consistent())
                shoebox.deallocate()
                assert (not shoebox.is_consistent())
            except Exception, e:
                print x0, y0, z0, x1, y1, z1
                raise
Ejemplo n.º 2
0
def test_allocate():
    for i in range(10):
        x0 = random.randint(0, 1000)
        y0 = random.randint(0, 1000)
        z0 = random.randint(0, 1000)
        x1 = random.randint(1, 10) + x0
        y1 = random.randint(1, 10) + y0
        z1 = random.randint(1, 10) + z0

        shoebox = Shoebox((x0, x1, y0, y1, z0, z1))
        shoebox.allocate()
        assert shoebox.data.all() == (z1 - z0, y1 - y0, x1 - x0)
        assert shoebox.mask.all() == (z1 - z0, y1 - y0, x1 - x0)
        shoebox.deallocate()
        assert shoebox.data.all() == (0, 0, 0)
        assert shoebox.mask.all() == (0, 0, 0)
Ejemplo n.º 3
0
def test_consistent():
    from dials.array_family import flex

    for i in range(1000):
        x0 = random.randint(0, 1000)
        y0 = random.randint(0, 1000)
        z0 = random.randint(0, 1000)
        x1 = random.randint(1, 10) + x0
        y1 = random.randint(1, 10) + y0
        z1 = random.randint(1, 10) + z0
        try:
            shoebox = Shoebox((x0, x1, y0, y1, z0, z1))
            assert not shoebox.is_consistent()
            shoebox.allocate()
            assert shoebox.is_consistent()
            shoebox.data = flex.real(flex.grid(20, 20, 20))
            assert not shoebox.is_consistent()
            shoebox.deallocate()
            assert not shoebox.is_consistent()
        except Exception:
            print(x0, y0, z0, x1, y1, z1)
            raise
Ejemplo n.º 4
0
    def tst_allocate(self):
        from random import randint
        from dials.model.data import Shoebox

        for i in range(10):

            x0 = randint(0, 1000)
            y0 = randint(0, 1000)
            z0 = randint(0, 1000)
            x1 = randint(1, 10) + x0
            y1 = randint(1, 10) + y0
            z1 = randint(1, 10) + z0

            shoebox = Shoebox((x0, x1, y0, y1, z0, z1))
            shoebox.allocate()
            assert (shoebox.data.all() == (z1 - z0, y1 - y0, x1 - x0))
            assert (shoebox.mask.all() == (z1 - z0, y1 - y0, x1 - x0))
            shoebox.deallocate()
            assert (shoebox.data.all() == (0, 0, 0))
            assert (shoebox.mask.all() == (0, 0, 0))

        # Test passed
        print 'OK'