Beispiel #1
0
    def test21(self):

        test_results_path = self.get_path_to_results()
        output_file = os.path.join(test_results_path,
                                   "test21" + self.store_version() + ".hdf5")
        if os.path.exists(output_file):
            os.remove(output_file)

        stars = Particles(2)
        stars.x = 1.0 | units.km
        stars.md = [[[1, 3], [2, 4], [3, 5]], [[4, 6], [5, 7], [6, 8]]]

        io.write_set_to_file(stars,
                             output_file,
                             "hdf5",
                             version=self.store_version())

        loaded = io.read_set_from_file(output_file,
                                       "hdf5",
                                       close_file=True,
                                       version=self.store_version(),
                                       copy_history=False)

        self.assertEqual(loaded[0].md, [[1, 3], [2, 4], [3, 5]])
        self.assertEqual(loaded[1].md, [[4, 6], [5, 7], [6, 8]])

        previous = loaded.previous_state()
        self.assertEqual(previous, None)
Beispiel #2
0
    def test15(self):

        test_results_path = self.get_path_to_results()
        output_file = os.path.join(test_results_path,
                                   "test15" + self.store_version() + ".hdf5")
        if os.path.exists(output_file):
            os.remove(output_file)

        stars = Particles(2)
        stars.x = 1.0 | units.km
        stars.md = [[[1, 3], [2, 4], [3, 5]], [[4, 6], [5, 7], [6, 8]]]

        io.write_set_to_file(stars,
                             output_file,
                             "hdf5",
                             version=self.store_version())
        processor = self.store_factory()(output_file,
                                         True,
                                         open_for_writing=True)
        loaded = processor.load()
        self.get_version_in_store(loaded)[0].md = [[3, 1], [3, 4], [5, 2]]
        self.assertEqual(
            self.get_version_in_store(loaded)[0].md, [[3, 1], [3, 4], [5, 2]])
        processor.close()

        loaded = io.read_set_from_file(output_file,
                                       "hdf5",
                                       version=self.store_version())
        self.assertEqual(loaded[0].md, [[3, 1], [3, 4], [5, 2]])
        self.assertEqual(loaded[1].md, [[4, 6], [5, 7], [6, 8]])
Beispiel #3
0
    def test13(self):
        test_results_path = self.get_path_to_results()
        output_file = os.path.join(test_results_path,
                                   "test13" + self.store_version() + ".hdf5")
        if os.path.exists(output_file):
            os.remove(output_file)

        stars = Particles(2)
        stars.x = 1.0 | units.km
        stars.md = [[1, 2, 3], [4, 5, 6]] | units.km

        io.write_set_to_file(stars,
                             output_file,
                             "hdf5",
                             version=self.store_version())

        loaded = io.read_set_from_file(output_file,
                                       "hdf5",
                                       version=self.store_version())
        self.assertEqual(loaded[0].md, [1, 2, 3] | units.km)
        self.assertEqual(loaded[1].md, [4, 5, 6] | units.km)

        self.assertEqual(loaded.md[0], [1, 2, 3] | units.km)
        self.assertEqual(loaded.md[1], [4, 5, 6] | units.km)

        self.assertEqual(
            self.get_version_in_store(loaded)[0].md, [1, 2, 3] | units.km)
Beispiel #4
0
    def test14(self):
        test_results_path = self.get_path_to_results()
        output_file = os.path.join(test_results_path, "test14"+self.store_version()+".hdf5")
        if os.path.exists(output_file):
            os.remove(output_file)

        stars = Particles(2)
        stars.x = 1.0  | units.km
        stars.md = [[[1,3],[2,4],[3,5]],[[4,6],[5,7],[6,8]]]
       

        io.write_set_to_file(stars, output_file, "hdf5", version = self.store_version())
        
        loaded = io.read_set_from_file(output_file, "hdf5", version = self.store_version())
        self.assertEquals(loaded[0].md, [[1,3],[2,4],[3,5]])
        self.assertEquals(loaded[1].md, [[4,6],[5,7],[6,8]])
        
        self.assertEquals(loaded.md[0], [[1,3],[2,4],[3,5]])
        self.assertEquals(loaded.md[1], [[4,6],[5,7],[6,8]])
Beispiel #5
0
    def test13(self):
        test_results_path = self.get_path_to_results()
        output_file = os.path.join(test_results_path, "test13"+self.store_version()+".hdf5")
        if os.path.exists(output_file):
            os.remove(output_file)

        stars = Particles(2)
        stars.x = 1.0  | units.km
        stars.md = [[1,2,3],[4,5,6]] | units.km
       

        io.write_set_to_file(stars, output_file, "hdf5", version = self.store_version())
        
        loaded = io.read_set_from_file(output_file, "hdf5", version = self.store_version())
        self.assertEquals(loaded[0].md, [1,2,3] | units.km)
        self.assertEquals(loaded[1].md, [4,5,6] | units.km)
        
        self.assertEquals(loaded.md[0], [1,2,3] | units.km)
        self.assertEquals(loaded.md[1], [4,5,6] | units.km)
         
        self.assertEquals(self.get_version_in_store(loaded)[0].md, [1,2,3] | units.km)
Beispiel #6
0
    def test15(self):
        
        test_results_path = self.get_path_to_results()
        output_file = os.path.join(test_results_path, "test15"+self.store_version()+".hdf5")
        if os.path.exists(output_file):
            os.remove(output_file)

        stars = Particles(2)
        stars.x = 1.0  | units.km
        stars.md = [[[1,3],[2,4],[3,5]],[[4,6],[5,7],[6,8]]]
       

        io.write_set_to_file(stars, output_file, "hdf5", version = self.store_version())
        processor = self.store_factory()(output_file, True, open_for_writing = True)
        loaded = processor.load()
        self.get_version_in_store(loaded)[0].md = [[3,1],[3,4],[5,2]] 
        self.assertEquals(self.get_version_in_store(loaded)[0].md, [[3,1],[3,4],[5,2]] )
        processor.close()
        
        loaded = io.read_set_from_file(output_file, "hdf5", version = self.store_version())
        self.assertEquals(loaded[0].md, [[3,1],[3,4],[5,2]])
        self.assertEquals(loaded[1].md, [[4,6],[5,7],[6,8]])