def write(self, out): if not self.args.no_headers: site_ct = (self.args.width * self.args.height / self.args.reduce ** 2) if self.args.partition: site_ct /= self.args.partition ** 2 self.write_headers(site_ct, out) sim = Simulator(DefaultTheme()) for i in xrange(self.args.num): field = sim.field(self.args.width, self.args.height) val_funcs = self.ins + self.outs region = Region.map(field, val_funcs) if self.args.partition: regions = region.partition(field, self.args.partition, val_funcs) else: regions = [region] if self.args.reduce != 1: regions = [Region.reduce(r, self.args.reduce) for r in regions] for region in regions: self.write_values(region, self.ins, out) self.write_values(region, self.outs, out) out.write('\n')
def write(self, out): if not self.args.no_headers: site_ct = self.args.width * self.args.height / self.args.reduce ** 2 if self.args.partition: site_ct /= self.args.partition ** 2 self.write_headers(site_ct, out) sim = Simulator(DefaultTheme()) for i in xrange(self.args.num): field = sim.field(self.args.width, self.args.height) val_funcs = self.ins + self.outs region = Region.map(field, val_funcs) if self.args.partition: regions = region.partition(field, self.args.partition, val_funcs) else: regions = [region] if self.args.reduce != 1: regions = [Region.reduce(r, self.args.reduce) for r in regions] for region in regions: self.write_values(region, self.ins, out) self.write_values(region, self.outs, out) out.write("\n")
def test_fill_flat(self): theme = DefaultTheme() for scale, width, height in [(8, 80,24), (4, 40, 12), (2, 20, 6)]: field = OilField(width, height) FlatFiller().fill(field) map = Region.map(field, val_funcs) region = Region.reduce(map, scale) self.assertEquals(len(region.sites), 30) for i in xrange(30): self.assertEquals(region.sites[i]['prob'], 10.0)
def test_visualize(self): theme = DefaultTheme() for scale, width, height in [(4, 40, 12), (2, 20, 6)]: field = OilField(width, height) OilFiller(theme).fill(field) DrillCostFiller(theme).fill(field) PotentialOilDepthFiller(theme).fill(field) ReservoirFiller(theme).fill(field) map = Region.map(field, val_funcs) print map region = Region.reduce(map, scale) self.assertEquals(len(region.sites), 30) print region