本文整理汇总了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()
示例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()
示例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()
示例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()
示例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)
示例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")