Exemplo n.º 1
0
  def tst_nearest_n(self):
    from random import uniform
    from dials.algorithms.profile_model.modeller import SingleSampler
    from math import floor
    width = 1000
    height = 1000
    scan_range = (2, 12)
    depth = scan_range[1] - scan_range[0]
    nz = 2
    sampler = SingleSampler(scan_range, nz)

    for i in range(1000):
      x = uniform(0, 1000)
      y = uniform(0, 1000)
      z = uniform(*scan_range)
      k = int(floor((z-scan_range[0]) * nz / depth))
      if k >= nz:
        k = nz - 1
      index0 = k
      index1 = sampler.nearest_n((x, y, z))
      assert(len(set(index1)) == len(index1))
      assert(index0 == index1[-1])
      for ind in index1:
        assert(abs(ind - k) <= 1)

    print 'OK'
Exemplo n.º 2
0
    def tst_nearest_n(self):
        from random import uniform
        from dials.algorithms.profile_model.modeller import SingleSampler
        from math import floor
        width = 1000
        height = 1000
        scan_range = (2, 12)
        depth = scan_range[1] - scan_range[0]
        nz = 2
        sampler = SingleSampler(scan_range, nz)

        for i in range(1000):
            x = uniform(0, 1000)
            y = uniform(0, 1000)
            z = uniform(*scan_range)
            k = int(floor((z - scan_range[0]) * nz / depth))
            if k >= nz:
                k = nz - 1
            index0 = k
            index1 = sampler.nearest_n(0, (x, y, z))
            assert (len(set(index1)) == len(index1))
            assert (index0 == index1[-1])
            for ind in index1:
                assert (abs(ind - k) <= 1)

        print 'OK'
Exemplo n.º 3
0
def test_nearest_n():
    from dials.algorithms.profile_model.modeller import SingleSampler

    scan_range = (2, 12)
    depth = scan_range[1] - scan_range[0]
    nz = 2
    sampler = SingleSampler(scan_range, nz)

    for i in range(1000):
        x = random.uniform(0, 1000)
        y = random.uniform(0, 1000)
        z = random.uniform(*scan_range)
        k = int(math.floor((z - scan_range[0]) * nz / depth))
        if k >= nz:
            k = nz - 1
        index0 = k
        index1 = sampler.nearest_n(0, (x, y, z))
        assert len(set(index1)) == len(index1)
        assert index0 == index1[-1]
        for ind in index1:
            assert abs(ind - k) <= 1