コード例 #1
0
 def test_hdf5_serialize_unserialize(self):
     filename = None
     try:
         w = world_gen("Dummy", 32, 16, 1, step=Step.get_by_name("full"))
         f = tempfile.NamedTemporaryFile(delete=False)
         f.close()
         filename = f.name
         serialized = save_world_to_hdf5(w, filename)
         unserialized = load_world_to_hdf5(filename)
         self.assertEqual(Set(w.layers.keys()),
                          Set(unserialized.layers.keys()))
         self.assertEqual(w.layers['humidity'].quantiles,
                          unserialized.layers['humidity'].quantiles)
         for l in w.layers.keys():
             self.assertEqual(w.layers[l], unserialized.layers[l],
                              "Comparing %s" % l)
         self.assertTrue(_equal(w.ocean_level, unserialized.ocean_level))
         self.assertEquals(w.seed, unserialized.seed)
         self.assertEquals(w.n_plates, unserialized.n_plates)
         self.assertEquals(w.step, unserialized.step)
         self.assertEqual(sorted(dir(w)), sorted(dir(unserialized)))
         #self.assertEqual(w, unserialized)
     finally:
         if filename:
             os.remove(filename)
コード例 #2
0
 def test_pickle_serialize_unserialize(self):
     w = world_gen("Dummy", 32, 16, 1, step=Step.get_by_name("full"))
     f = tempfile.NamedTemporaryFile(delete=False).name
     w.to_pickle_file(f)
     unserialized = World.from_pickle_file(f)
     os.remove(f)
     self.assertEqual(w.elevation['data'],       unserialized.elevation['data'])
     self.assertEqual(w.elevation['thresholds'], unserialized.elevation['thresholds'])
     self.assertEqual(w.ocean,                   unserialized.ocean)
     self.assertEqual(w.biome,                   unserialized.biome)
     self.assertEqual(w.humidity,                unserialized.humidity)
     self.assertEqual(w.irrigation,              unserialized.irrigation)
     self.assertEqual(w.permeability,            unserialized.permeability)
     self.assertEqual(w.watermap,                unserialized.watermap)
     self.assertEqual(w.precipitation,           unserialized.precipitation)
     self.assertEqual(w.temperature,             unserialized.temperature)
     self.assertEqual(w.sea_depth,               unserialized.sea_depth)
     self.assertEquals(w.seed,                   unserialized.seed)
     self.assertEquals(w.n_plates,               unserialized.n_plates)
     self.assertEquals(w.ocean_level,            unserialized.ocean_level)
     self.assertEquals(w.lake_map,               unserialized.lake_map)
     self.assertEquals(w.river_map,              unserialized.river_map)
     self.assertEquals(w.step,                   unserialized.step)
     self.assertEqual(_sort(dir(w)), _sort(dir(unserialized)))
     self.assertEqual(w, unserialized)
コード例 #3
0
 def test_protobuf_serialize_unserialize(self):
     w = world_gen("Dummy",
                   32,
                   16,
                   1, [.874, .765, .594, .439, .366, .124],
                   [.941, .778, .507, .236, 0.073, .014, .002],
                   step=Step.get_by_name("full"))
     serialized = w.protobuf_serialize()
     unserialized = World.protobuf_unserialize(serialized)
     self.assertTrue(
         _equal(w.elevation['data'], unserialized.elevation['data']))
     self.assertEqual(w.elevation['thresholds'],
                      unserialized.elevation['thresholds'])
     self.assertTrue(_equal(w.ocean, unserialized.ocean))
     self.assertTrue(_equal(w.biome, unserialized.biome))
     self.assertTrue(_equal(w.humidity, unserialized.humidity))
     self.assertTrue(_equal(w.irrigation, unserialized.irrigation))
     self.assertTrue(_equal(w.permeability, unserialized.permeability))
     self.assertTrue(_equal(w.watermap, unserialized.watermap))
     self.assertTrue(_equal(w.precipitation, unserialized.precipitation))
     self.assertTrue(_equal(w.temperature, unserialized.temperature))
     self.assertTrue(_equal(w.sea_depth, unserialized.sea_depth))
     self.assertEquals(w.seed, unserialized.seed)
     self.assertEquals(w.n_plates, unserialized.n_plates)
     self.assertTrue(_equal(w.ocean_level, unserialized.ocean_level))
     self.assertTrue(_equal(w.lake_map, unserialized.lake_map))
     self.assertTrue(_equal(w.river_map, unserialized.river_map))
     self.assertEquals(w.step, unserialized.step)
     self.assertEqual(sorted(dir(w)), sorted(dir(unserialized)))
     self.assertEqual(w, unserialized)
コード例 #4
0
 def test_world_gen_does_not_explode_badly(self):
     # FIXME remove me when proper tests are in place
     # Very stupid test that just verify nothing explode badly
     world_gen("Dummy",
               32,
               16,
               1, [.874, .765, .594, .439, .366, .124],
               [.941, .778, .507, .236, 0.073, .014, .002],
               step=Step.get_by_name("full"))
コード例 #5
0
 def test_protobuf_serialize_unserialize(self):
     w = world_gen("Dummy", 32, 16, 1, step=Step.get_by_name("full"))
     serialized = w.protobuf_serialize()
     unserialized = World.protobuf_unserialize(serialized)
     self.assertEqual(set(w.layers.keys()), set(unserialized.layers.keys()))
     for l in w.layers.keys():
         self.assertEqual(w.layers[l], unserialized.layers[l], "Comparing %s" % l)
     self.assertTrue(_equal(w.ocean_level,       unserialized.ocean_level))
     self.assertEquals(w.seed,                   unserialized.seed)
     self.assertEquals(w.n_plates,               unserialized.n_plates)
     self.assertEquals(w.step,                   unserialized.step)
     self.assertEqual(sorted(dir(w)),            sorted(dir(unserialized)))
     self.assertEqual(w, unserialized)
コード例 #6
0
 def test_protobuf_serialize_unserialize(self):
     w = world_gen("Dummy", 32, 16, 1, step=Step.get_by_name("full"))
     serialized = w.protobuf_serialize()
     unserialized = World.protobuf_unserialize(serialized)
     self.assertEqual(Set(w.layers.keys()), Set(unserialized.layers.keys()))
     for l in w.layers.keys():
         self.assertEqual(w.layers[l], unserialized.layers[l],
                          "Comparing %s" % l)
     self.assertTrue(_equal(w.ocean_level, unserialized.ocean_level))
     self.assertEquals(w.seed, unserialized.seed)
     self.assertEquals(w.n_plates, unserialized.n_plates)
     self.assertEquals(w.step, unserialized.step)
     self.assertEqual(sorted(dir(w)), sorted(dir(unserialized)))
     self.assertEqual(w, unserialized)
コード例 #7
0
 def test_hdf5_serialize_unserialize(self):
     filename = None
     try:
         w = world_gen("Dummy", 32, 16, 1, step=Step.get_by_name("full"))
         f = tempfile.NamedTemporaryFile(delete=False)
         f.close()
         filename = f.name
         serialized = save_world_to_hdf5(w, filename)
         unserialized = load_world_to_hdf5(filename)
         self.assertTrue(
             _equal(w.elevation['data'], unserialized.elevation['data']))
         self.assertEqual(w.elevation['thresholds'],
                          unserialized.elevation['thresholds'])
         self.assertTrue(_equal(w.plates, unserialized.plates))
         self.assertTrue(_equal(w.ocean, unserialized.ocean))
         self.assertTrue(_equal(w.biome, unserialized.biome))
         self.assertTrue(
             _equal(w.humidity['quantiles'],
                    unserialized.humidity['quantiles']))
         self.assertTrue(
             _equal(w.humidity['data'], unserialized.humidity['data']))
         self.assertTrue(_equal(w.humidity, unserialized.humidity))
         self.assertTrue(_equal(w.irrigation, unserialized.irrigation))
         self.assertTrue(_equal(w.permeability, unserialized.permeability))
         self.assertTrue(_equal(w.watermap, unserialized.watermap))
         self.assertTrue(
             _equal(w.precipitation['thresholds'],
                    unserialized.precipitation['thresholds']))
         self.assertTrue(
             _equal(w.precipitation['data'],
                    unserialized.precipitation['data']))
         self.assertTrue(_equal(w.precipitation,
                                unserialized.precipitation))
         self.assertTrue(_equal(w.temperature, unserialized.temperature))
         self.assertTrue(_equal(w.sea_depth, unserialized.sea_depth))
         self.assertTrue(_equal(w.ocean_level, unserialized.ocean_level))
         self.assertTrue(_equal(w.lake_map, unserialized.lake_map))
         self.assertTrue(_equal(w.river_map, unserialized.river_map))
         self.assertTrue(_equal(w.icecap, unserialized.icecap))
         self.assertEquals(w.seed, unserialized.seed)
         self.assertEquals(w.n_plates, unserialized.n_plates)
         self.assertEquals(w.step, unserialized.step)
         self.assertEqual(sorted(dir(w)), sorted(dir(unserialized)))
         #self.assertEqual(w, unserialized)
     finally:
         if filename:
             os.remove(filename)
コード例 #8
0
 def test_hdf5_serialize_unserialize(self):
     filename = None
     try:
         w = world_gen("Dummy", 32, 16, 1, step=Step.get_by_name("full"))
         f = tempfile.NamedTemporaryFile(delete=False)
         f.close()
         filename = f.name
         serialized = save_world_to_hdf5(w, filename)
         unserialized = load_world_to_hdf5(filename)
         self.assertEqual(set(w.layers.keys()), set(unserialized.layers.keys()))
         self.assertEqual(w.layers['humidity'].quantiles, unserialized.layers['humidity'].quantiles)
         for l in w.layers.keys():
             self.assertEqual(w.layers[l], unserialized.layers[l], "Comparing %s" % l)
         self.assertTrue(_equal(w.ocean_level,       unserialized.ocean_level))
         self.assertEquals(w.seed,                   unserialized.seed)
         self.assertEquals(w.n_plates,               unserialized.n_plates)
         self.assertEquals(w.step,                   unserialized.step)
         self.assertEqual(sorted(dir(w)),            sorted(dir(unserialized)))
         #self.assertEqual(w, unserialized)
     finally:
         if filename:
             os.remove(filename)
コード例 #9
0
 def test_protobuf_serialize_unserialize(self):
     w = world_gen("Dummy", 32, 16, 1, step=Step.get_by_name("full"))
     serialized = w.protobuf_serialize()
     unserialized = World.protobuf_unserialize(serialized)
     self.assertEqual(w.elevation['data'],       unserialized.elevation['data'])
     self.assertEqual(w.elevation['thresholds'], unserialized.elevation['thresholds'])
     self.assertEqual(w.ocean,                   unserialized.ocean)
     self.assertEqual(w.biome,                   unserialized.biome)
     self.assertEqual(w.humidity,                unserialized.humidity)
     self.assertEqual(w.irrigation,              unserialized.irrigation)
     self.assertEqual(w.permeability,            unserialized.permeability)
     self.assertEqual(w.watermap,                unserialized.watermap)
     self.assertEqual(w.precipitation,           unserialized.precipitation)
     self.assertEqual(w.temperature,             unserialized.temperature)
     self.assertEqual(w.sea_depth,               unserialized.sea_depth)
     self.assertEquals(w.seed,                   unserialized.seed)
     self.assertEquals(w.n_plates,               unserialized.n_plates)
     self.assertEquals(w.ocean_level,            unserialized.ocean_level)
     self.assertEquals(w.lake_map,               unserialized.lake_map)
     self.assertEquals(w.river_map,              unserialized.river_map)
     self.assertEquals(w.step,                   unserialized.step)
     self.assertEqual(_sort(dir(w)), _sort(dir(unserialized)))
     self.assertEqual(w, unserialized)
コード例 #10
0
 def test_hdf5_serialize_unserialize(self):
     filename = None
     try:
         w = world_gen("Dummy", 32, 16, 1, step=Step.get_by_name("full"))
         f = tempfile.NamedTemporaryFile(delete=False)
         f.close()
         filename = f.name
         serialized = save_world_to_hdf5(w, filename)
         unserialized = load_world_to_hdf5(filename)
         self.assertTrue(_equal(w.elevation['data'], unserialized.elevation['data']))
         self.assertEqual(w.elevation['thresholds'], unserialized.elevation['thresholds'])
         self.assertTrue(_equal(w.ocean,             unserialized.ocean))
         self.assertTrue(_equal(w.biome,             unserialized.biome))
         self.assertTrue(_equal(w.humidity['quantiles'], unserialized.humidity['quantiles']))
         self.assertTrue(_equal(w.humidity['data'],  unserialized.humidity['data']))
         self.assertTrue(_equal(w.humidity,          unserialized.humidity))
         self.assertTrue(_equal(w.irrigation,        unserialized.irrigation))
         self.assertTrue(_equal(w.permeability,      unserialized.permeability))
         self.assertTrue(_equal(w.watermap,          unserialized.watermap))
         self.assertTrue(_equal(w.precipitation['thresholds'], unserialized.precipitation['thresholds']))
         self.assertTrue(_equal(w.precipitation['data'], unserialized.precipitation['data']))
         self.assertTrue(_equal(w.precipitation,     unserialized.precipitation))
         self.assertTrue(_equal(w.temperature,       unserialized.temperature))
         self.assertTrue(_equal(w.sea_depth,         unserialized.sea_depth))
         self.assertTrue(_equal(w.ocean_level,       unserialized.ocean_level))
         self.assertTrue(_equal(w.lake_map,          unserialized.lake_map))
         self.assertTrue(_equal(w.river_map,         unserialized.river_map))
         self.assertTrue(_equal(w.icecap,            unserialized.icecap))
         self.assertEquals(w.seed,                   unserialized.seed)
         self.assertEquals(w.n_plates,               unserialized.n_plates)
         self.assertEquals(w.step,                   unserialized.step)
         self.assertEqual(sorted(dir(w)),            sorted(dir(unserialized)))
         #self.assertEqual(w, unserialized)
     finally:
         if filename:
             os.remove(filename)
コード例 #11
0
 def test_world_gen_does_not_explode_badly(self):
     # FIXME remove me when proper tests are in place
     # Very stupid test that just verify nothing explode badly
     world_gen("Dummy", 32, 16, 1, step=Step.get_by_name("full"))
コード例 #12
0
 def test_protobuf_serialize_unserialize(self):
     w = world_gen("Dummy", 32, 16, 1, [.874, .765, .594, .439, .366, .124], [.941, .778, .507, .236, 0.073, .014, .002], step=Step.get_by_name("full"))
     serialized = w.protobuf_serialize()
     unserialized = World.protobuf_unserialize(serialized)
     self.assertTrue(_equal(w.elevation['data'], unserialized.elevation['data']))
     self.assertEqual(w.elevation['thresholds'], unserialized.elevation['thresholds'])
     self.assertTrue(_equal(w.ocean,             unserialized.ocean))
     self.assertTrue(_equal(w.biome,             unserialized.biome))
     self.assertTrue(_equal(w.humidity,          unserialized.humidity))
     self.assertTrue(_equal(w.irrigation,        unserialized.irrigation))
     self.assertTrue(_equal(w.permeability,      unserialized.permeability))
     self.assertTrue(_equal(w.watermap,          unserialized.watermap))
     self.assertTrue(_equal(w.precipitation,     unserialized.precipitation))
     self.assertTrue(_equal(w.temperature,       unserialized.temperature))
     self.assertTrue(_equal(w.sea_depth,         unserialized.sea_depth))
     self.assertEquals(w.seed,                   unserialized.seed)
     self.assertEquals(w.n_plates,               unserialized.n_plates)
     self.assertTrue(_equal(w.ocean_level,       unserialized.ocean_level))
     self.assertTrue(_equal(w.lake_map,          unserialized.lake_map))
     self.assertTrue(_equal(w.river_map,         unserialized.river_map))
     self.assertEquals(w.step,                   unserialized.step)
     self.assertEqual(sorted(dir(w)),            sorted(dir(unserialized)))
     self.assertEqual(w, unserialized)
コード例 #13
0
ファイル: generation_test.py プロジェクト: pangal/worldengine
 def test_world_gen_does_not_explode_badly(self):
     # FIXME remove me when proper tests are in place
     # Very stupid test that just verify nothing explode badly
     world_gen("Dummy", 32, 16, 1, [.874, .765, .594, .439, .366, .124], [.941, .778, .507, .236, 0.073, .014, .002], step=Step.get_by_name("full"))