本文整理汇总了Python中hftools.dataset.DataBlock.values_from_property方法的典型用法代码示例。如果您正苦于以下问题:Python DataBlock.values_from_property方法的具体用法?Python DataBlock.values_from_property怎么用?Python DataBlock.values_from_property使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类hftools.dataset.DataBlock
的用法示例。
在下文中一共展示了DataBlock.values_from_property方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_5
# 需要导入模块: from hftools.dataset import DataBlock [as 别名]
# 或者: from hftools.dataset.DataBlock import values_from_property [as 别名]
def test_5(self):
d = DataBlock()
d.comments = Comments(["Vgs=13", "Ig=14", "Datetime=2011-10-11 20:11:02",
"Vds=-13", "Calibration=SOLT"])
fi = DimSweep("Freq", 3)
gi = DimSweep("g", 4)
d["Vds"] = hfarray([1, 2, 3], dims=(fi,))
d["Id"] = hfarray([1, 2, 3, 4], dims=(gi,))
d.comments.property["Ig"].unit = "mA"
d.guess_units()
d.values_from_property()
self.assertEqual(d.Vds.unit, "V")
self.assertAllclose(d.Vds, [1, 2, 3])
self.assertEqual(d.Id.unit, "A")
self.assertAllclose(d.Id, [1, 2, 3, 4])
self.assertEqual(d.Freq.unit, "Hz")
self.assertEqual(d.comments.property["Vgs"].unit, "V")
self.assertEqual(d.comments.property["Ig"].unit, "mA")
self.assertEqual(d.Ig, 14)
self.assertEqual(d.Vgs, 13)
self.assertEqual(d.Ig.unit, "mA")
self.assertEqual(d.Vgs.unit, "V")
self.assertTrue("Datetime" in d.allvarnames)
示例2: test_1
# 需要导入模块: from hftools.dataset import DataBlock [as 别名]
# 或者: from hftools.dataset.DataBlock import values_from_property [as 别名]
def test_1(self):
d = DataBlock()
fi = DimSweep("Freq", 3)
gi = DimSweep("g", 4)
d["Vds"] = hfarray([1, 2, 3], dims=(fi,))
d["Id"] = hfarray([1, 2, 3, 4], dims=(gi,))
d.guess_units()
d.values_from_property()
self.assertEqual(d.Vds.unit, "V")
self.assertAllclose(d.Vds, [1, 2, 3])
self.assertEqual(d.Id.unit, "A")
self.assertAllclose(d.Id, [1, 2, 3, 4])
self.assertEqual(d.Freq.unit, "Hz")
示例3: read_hdf5
# 需要导入模块: from hftools.dataset import DataBlock [as 别名]
# 或者: from hftools.dataset.DataBlock import values_from_property [as 别名]
def read_hdf5(h5file, name="datablock", **kw):
if isinstance(h5file, string_types):
fil = h5py.File(h5file, "r")
else:
fil = h5file
db = DataBlock()
grp = fil[name]
blockname = grp.attrs["Blockname"]
if blockname.lower() == "none":
blockname = None
db.blockname = blockname
comments = grp["Comments"]
if "fullcomments" in comments and len(comments["fullcomments"]):
db.comments = Comments([cast_unicode(x).strip() for x in np.array(comments["fullcomments"])])
else:
db.comments = Comments()
ivardata = grp["ivardata"]
vardata = grp["vardata"]
for k in ivardata:
v = ivardata[k]
datadtype = v.attrs[r"info\dtype"] or None
dimcls = dims_dict.get(v.attrs[r"info\class"], DimRep)
unit = str(v.attrs.get(r"info\unit", "none"))
if unit.lower() == "none":
unit = None
vdata = np.array(np.array(v), dtype=datadtype)
dim = dimcls(k, vdata, unit=unit)
db[k] = dim
for k in vardata:
v = vardata[k]
datadtype = v.attrs[r"data\dtype"] or None
dims = tuple(db.ivardata[cast_unicode(dimname)] for dimname in v.attrs[r"info\name"])
unit = cast_unicode(v.attrs.get(r"data\unit", "none"))
if unit.lower() == "none":
unit = None
db[k] = hfarray(np.array(v), dtype=datadtype, dims=dims, unit=unit)
if isinstance(h5file, string_types):
fil.close()
if kw.get("property_to_vars", False):
db.values_from_property()
return db