def test_vec3_double(vec3_double): index = make_spatial_index(vec3_double) x, y, z = zip(*vec3_double) x0, x1, y0, y1, z0, z1 = ( int(min(x)), int(max(x)), int(min(y)), int(max(y)), int(min(z)), int(max(z)), ) for i in range(10): xx0 = random.randint(x0, x1) xx1 = random.randint(x0, x1) yy0 = random.randint(y0, y1) yy1 = random.randint(y0, y1) zz0 = random.randint(z0, z1) zz1 = random.randint(z0, z1) rg = ( min(xx0, xx1), max(xx0, xx1) + 1, min(yy0, yy1), max(yy0, yy1) + 1, min(zz0, zz1), max(zz0, zz1) + 1, ) idx = index.query_range(rg) for j in idx: assert inside3d(rg, vec3_double[j]) for j in set(range(len(vec3_double))).difference(set(idx)): assert not inside3d(rg, vec3_double[j])
def tst_vec2_double(self, num): from random import randint index = make_spatial_index(self.vec2_double) x, y = zip(*self.vec2_double) x0, x1, y0, y1 = (int(min(x)), int(max(x)), int(min(y)), int(max(y))) for i in range(num): xx0 = randint(x0, x1) xx1 = randint(x0, x1) yy0 = randint(y0, y1) yy1 = randint(y0, y1) rg = (min(xx0, xx1), max(xx0, xx1) + 1, min(yy0, yy1), max(yy0, yy1) + 1) idx = index.query_range(rg) for j in idx: assert (self.inside2d(rg, self.vec2_double[j])) for j in set(range(len(self.vec2_double))).difference(set(idx)): assert (not self.inside2d(rg, self.vec2_double[j])) print 'OK'
def tst_vec2_double(self, num): from random import randint index = make_spatial_index(self.vec2_double) x, y = zip(*self.vec2_double) x0, x1, y0, y1 = (int(min(x)), int(max(x)), int(min(y)), int(max(y))) for i in range(num): xx0 = randint(x0, x1) xx1 = randint(x0, x1) yy0 = randint(y0, y1) yy1 = randint(y0, y1) rg = (min(xx0, xx1), max(xx0, xx1)+1, min(yy0, yy1), max(yy0, yy1)+1) idx = index.query_range(rg) for j in idx: assert(self.inside2d(rg, self.vec2_double[j])) for j in set(range(len(self.vec2_double))).difference(set(idx)): assert(not self.inside2d(rg, self.vec2_double[j])) print 'OK'