def tst_count_mask_values(self): from dials.model.data import Shoebox from random import randint, sample for i in range(10): x0 = randint(0, 90) y0 = randint(0, 90) z0 = randint(0, 90) 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() maxnum = len(shoebox.mask) num = randint(1, maxnum) indices = sample(list(range(maxnum)), num) value = (1 << 2) for i in indices: shoebox.mask[i] = value assert (shoebox.count_mask_values(value) == num) # Test passed print 'OK'
def test_count_mask_values(): for i in range(10): x0 = random.randint(0, 90) y0 = random.randint(0, 90) z0 = random.randint(0, 90) 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() maxnum = len(shoebox.mask) num = random.randint(1, maxnum) indices = random.sample(list(range(maxnum)), num) value = 1 << 2 for i in indices: shoebox.mask[i] = value assert shoebox.count_mask_values(value) == num