def _get_flat_structure(self, shape): if self.fs is None: def make_size(x): x = int(np.ceil(x)) if x % 2 == 0: x += 1 return x ax = make_size(shape[0] * self.ratios[0]) ay = make_size(shape[1] * self.ratios[1]) area = (ax, ay) if np.min(area) == 1: logger.warning('Area is too small. Ratios: %s shape: %s area: %s' % (self.ratios, shape, area)) logger.info('ratios: %s shape: %s area: %s' % (self.ratios, shape, area)) self.fs = FlatStructure(shape=shape, neighborarea=area) return self.fs
def test_distance_neighbor_dist1(): gs = FlatStructure((100, 100), (1, 1)) D = gs.get_distances() assert_allclose(D, 0)
def test_distance_neighbor_dist3(): gs = FlatStructure((100, 100), (3, 3)) D = gs.get_distances() assert_allclose(np.max(D), np.sqrt(2))