当前位置: 首页>>代码示例>>Python>>正文


Python DataBlock.c方法代码示例

本文整理汇总了Python中hftools.dataset.DataBlock.c方法的典型用法代码示例。如果您正苦于以下问题:Python DataBlock.c方法的具体用法?Python DataBlock.c怎么用?Python DataBlock.c使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在hftools.dataset.DataBlock的用法示例。


在下文中一共展示了DataBlock.c方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_11

# 需要导入模块: from hftools.dataset import DataBlock [as 别名]
# 或者: from hftools.dataset.DataBlock import c [as 别名]
    def test_11(self):
        ia = DimSweep("a", 1)
        d = DataBlock()
        d.comments = Comments(["Hej=10"])
#        import pdb;pdb.set_trace()
        d.b = hfarray([u"kalle"], dims=(ia, ), unit="V")
        d.c = hfarray(u"kalle")
        fname = testpath / "testdata/hdf5/v02/savetest/res_11.hdf5"
        self.savefun[0](d, fname)
        d2 = readfun(fname)
        self.assertEqual(d2.b[0], u"kalle")
        self.assertEqual(d2.c, u"kalle")
        fname.unlink()
开发者ID:extrakteon,项目名称:hftools-1,代码行数:15,代码来源:test_hdf5_v02.py

示例2: test_cant_append

# 需要导入模块: from hftools.dataset import DataBlock [as 别名]
# 或者: from hftools.dataset.DataBlock import c [as 别名]
 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()
开发者ID:extrakteon,项目名称:hftools-1,代码行数:16,代码来源:test_hdf5_v02.py

示例3: test_2

# 需要导入模块: from hftools.dataset import DataBlock [as 别名]
# 或者: from hftools.dataset.DataBlock import c [as 别名]
 def test_2(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,))
     d2.c = hfarray(2)
     fname = testpath / "testdata/hdf5/v02/savetest/res_1.hdf5"
     with hdf5context(fname, mode="w") as fil:
         savefun(d1, fil, expandable=True, expanddim=iexpand)
         append_hdf5(d2, fil, expanddim=iexpand)
     d = readfun(fname)
     self.assertAllclose(hfarray([[2, 3]], dims=(i1, i2)), d.b)
     self.assertAllclose(hfarray([3, 2], dims=(i2,)), d.c)
     self.assertEqual(d.ivardata["a"].unit, "s")
     self.assertEqual(d.ivardata["INDEX"].unit, "s")
     self.assertEqual(d.ivardata["a"].outputformat, "%d")
     self.assertEqual(d.ivardata["INDEX"].outputformat, "%d")
     self.assertEqual(d.b.outputformat, "%d")
     fname.unlink()
开发者ID:extrakteon,项目名称:hftools-1,代码行数:25,代码来源:test_hdf5_v02.py

示例4: test_3

# 需要导入模块: from hftools.dataset import DataBlock [as 别名]
# 或者: from hftools.dataset.DataBlock import c [as 别名]
 def test_3(self):
     d = DataBlock()
     d.comments = Comments(["Hej=10", "Svejs=11"])
     dims = (DimSweep("f", 3, outputformat="%.1f"),
             DimSweep("i", 2, outputformat="%.0f"),
             DimSweep("j", 2, outputformat="%.0f"), )
     d.c = hfarray([[[1, 2], [3, 4]],
                    [[10, 20], [30, 40]],
                    [[10, 20], [30, 40]]],
                   dims=dims,
                   outputformat="%.2f")
     fname = testpath / "testdata/hdf5/v02/savetest/res_3.hdf5"
     self.savefun[0](d, fname)
     fname.unlink()
开发者ID:extrakteon,项目名称:hftools-1,代码行数:16,代码来源:test_hdf5_v02.py

示例5: test_3

# 需要导入模块: from hftools.dataset import DataBlock [as 别名]
# 或者: from hftools.dataset.DataBlock import c [as 别名]
 def test_3(self):
     d = DataBlock()
     d.comments = Comments(["Hej=10", "Svejs=11"])
     dims = (DimSweep("f", 3, outputformat="%.1f"),
             DimSweep("i", 2, outputformat="%.0f"),
             DimSweep("j", 2, outputformat="%.0f"),)
     d.c = hfarray([[[1, 2], [3, 4]],
                    [[10, 20], [30, 40]],
                    [[10, 20], [30, 40]]], dims=dims, outputformat="%.2f")
     f1 = testpath / "testdata/sp-data/savetest/res_3.txt"
     f2 = testpath / "testdata/sp-data/savetest/facit_3.txt"
     hftools.file_formats.spdata.save_spdata(d, f1)
     with open(f1) as resfil:
         with open(f2) as facitfil:
             for idx, (rad1, rad2) in enumerate(zip(resfil, facitfil)):
                 msg = "\nFailed on line %d\n  result: %r\n  facit: %r"
                 args = (idx + 1, rad1, rad2)
                 self.assertEqual(rad1, rad2, msg=msg % args)
开发者ID:arsenovic,项目名称:hftools,代码行数:20,代码来源:test_spdata.py

示例6: test_error_1

# 需要导入模块: from hftools.dataset import DataBlock [as 别名]
# 或者: from hftools.dataset.DataBlock import c [as 别名]
    def test_error_1(self):
        filenames = [testpath / "testdata/sp-data/nosuchfile.txt"]
        self.assertRaises(IOError, hftools.file_formats.read_data, filenames)


class TestInitCiti_1(base_test.Test_1):
    readfun = [hftools.file_formats.read_data]
    basepath = testpath
    dirname = "citi"
    extension = ".citi"
    readpars = dict(verbose=False)

# There is no idea to make tests based on Test_2 and Test_3 as they are
# dB/arg, mag/arg


if __name__ == '__main__':
    d = DataBlock()
    d.comments = Comments(["Hej=10", "Svejs=11"])
    dims = (DimSweep("f", 3, outputformat="%.1f"),
            DimSweep("i", 2, outputformat="%.0f"),
            DimSweep("j", 2, outputformat="%.0f"), )
    d.c = hfarray([[[1, 2], [3, 4]],
                   [[10, 20], [30, 40]],
                   [[10, 20], [30, 40]]],
                  dims=dims, outputformat="%.2f")
    save = hftools.file_formats.spdata.save_spdata
    save(d, testpath / "testdata/sp-data/savetest/res_3.txt")
    d2 = hftools.file_formats.read_spdata(testpath / "testdata/sp-data/a.txt")
开发者ID:arsenovic,项目名称:hftools,代码行数:31,代码来源:test_init.py


注:本文中的hftools.dataset.DataBlock.c方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。