Пример #1
0
    def test_wrong_version_2(self):
        ia = DimSweep("a", 1, unit="")
        d1 = DataBlock()
        d1.b = hfarray([2], dims=(ia,))
        d2 = DataBlock()
        d2.b = hfarray([3], dims=(ia,))
        fname = testpath / "testdata/hdf5/v02/savetest/res_1.hdf5"

        with hdf5context(fname, mode="w") as fil:
            save_hdf5_v01(d1, fil)
            self.assertRaises(Exception, append_hdf5, d2, fil)
#            append_hdf5(d2, fil)
        fname.unlink()
Пример #2
0
    def test_wrong_version_1(self):
        ia = DimSweep("a", 1, unit="")
        d1 = DataBlock()
        d1.b = hfarray([2], dims=(ia, ))
        d2 = DataBlock()
        d2.b = hfarray([3], dims=(ia, ))
        fname = testpath / "testdata/hdf5/v02/savetest/res_1.hdf5"

        with hdf5context(fname, mode="w") as fil:
            save_hdf5_v01(d1, fil)
            self.assertRaises(Exception, append_hdf5, d2, fil)
#            append_hdf5(d2, fil)
        fname.unlink()
Пример #3
0
 def test_cant_append(self):
     i1 = DimSweep("a", 1, unit="s", outputformat="")
     i2 = DimSweep("INDEX", 2, unit="s")
     iexpand = DimRep("INDEX", 1, unit="s", outputformat="")
     d1 = DataBlock()
     d1.b = hfarray([2], dims=(i1,), outputformat="")
     d1.c = hfarray(3)
     d2 = DataBlock()
     d2.b = hfarray([3], dims=(i1,))
     fname = testpath / "testdata/hdf5/v02/savetest/res_1.hdf5"
     with hdf5context(fname, mode="w") as fil:
         savefun(d1, fil, expandable=True, expanddim=iexpand)
         self.assertRaises(ValueError, append_hdf5, d2, fil)
     fname.unlink()
Пример #4
0
 def test_cant_append(self):
     i1 = DimSweep("a", 1, unit="s", outputformat="")
     i2 = DimSweep("INDEX", 2, unit="s")
     iexpand = DimRep("INDEX", 1, unit="s", outputformat="")
     d1 = DataBlock()
     d1.b = hfarray([2], dims=(i1, ), outputformat="")
     d1.c = hfarray(3)
     d2 = DataBlock()
     d2.b = hfarray([3], dims=(i1, ))
     fname = testpath / "testdata/hdf5/v02/savetest/res_1.hdf5"
     with hdf5context(fname, mode="w") as fil:
         savefun(d1, fil, expandable=True, expanddim=iexpand)
         self.assertRaises(ValueError, append_hdf5, d2, fil)
     fname.unlink()
Пример #5
0
 def test_1(self):
     i1 = DimSweep("a", 1, unit="s", outputformat="")
     i2 = DimSweep("INDEX", 2)
     d1 = DataBlock()
     d1.b = hfarray([2], dims=(i1,), outputformat="")
     d2 = DataBlock()
     d2.b = hfarray([3], dims=(i1,))
     fname = testpath / "testdata/hdf5/v02/savetest/res_1.hdf5"
     with hdf5context(fname, mode="w") as fil:
         savefun(d1, fil, expandable=True)
         append_hdf5(d2, fil)
     d = readfun(fname)
     self.assertAllclose(hfarray([[2, 3]], dims=(i1, i2)), d.b)
     self.assertEqual(d.ivardata["a"].unit, "s")
     self.assertEqual(d.ivardata["a"].outputformat, "%d")
     self.assertEqual(d.b.outputformat, "%d")
     fname.unlink()
Пример #6
0
 def test_1(self):
     i1 = DimSweep("a", 1, unit="s", outputformat="")
     i2 = DimSweep("INDEX", 2)
     d1 = DataBlock()
     d1.b = hfarray([2], dims=(i1, ), outputformat="")
     d2 = DataBlock()
     d2.b = hfarray([3], dims=(i1, ))
     fname = testpath / "testdata/hdf5/v02/savetest/res_1.hdf5"
     with hdf5context(fname, mode="w") as fil:
         savefun(d1, fil, expandable=True)
         append_hdf5(d2, fil)
     d = readfun(fname)
     self.assertAllclose(hfarray([[2, 3]], dims=(i1, i2)), d.b)
     self.assertEqual(d.ivardata["a"].unit, "s")
     self.assertEqual(d.ivardata["a"].outputformat, "%d")
     self.assertEqual(d.b.outputformat, "%d")
     fname.unlink()