def test_table1(self): c = Comments(["apa:10", "kul: kasdjlkj"]) x = c.table() self.assertEqual(x, [' Comments '.center(77, "-"), 'Key ' + 'Value ', '--- ' + '-' * 73, 'apa 10.0 ' + ' ', 'kul kasdjlkj ' + ' '])
def test_table2(self): c = Comments(["apa:10", "kul: kasdjlkjlo aloksd olakds okal " + "sdlokasdolkaolsdola " + "sdolasdlk oasdasiukweyrkh sdfsadf "]) x = c.table() self.assertEqual(x, [' Comments '.center(77, "-"), 'Key ' + 'Value ', '--- ' + '-' * 73, 'apa 10.0 ' + ' ', 'kul kasdjlkjlo aloksd olakds okal ' + 'sdlokasdolkaolsdola sdolasdlk oasdasiukweyr'])
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)
def test_copy_2(self): d = DataBlock() fi = DimSweep("Freq[Hz]", 3) dims = (fi, ) d.comments = Comments(["Hej=10"]) d["a"] = hfarray([1, 2, 3], dims=dims, outputformat="%.5f", unit="V") d["b"] = hfarray([10, 20, 30], dims=dims, outputformat="%.7f", unit="A") c = d.copy() self.assertEqual(c.allvarnames, d.allvarnames) self.assertEqual(c.vardata.keys(), d.vardata.keys()) self.assertEqual(c.ivardata.keys(), d.ivardata.keys()) self.assertAllclose(c["Freq[Hz]"], d["Freq[Hz]"]) self.assertAllclose(d.a, [1, 2, 3]) self.assertAllclose(c.a, d.a) self.assertAllclose(c.b, d.b) self.assertFalse(id(d.comments) == id(c.comments)) c.a[0] = 7 c.b[0] = 7 self.assertAllclose(c.a, [7, 2, 3]) self.assertAllclose(c.b, [7, 20, 30]) self.assertAllclose(d.a, [1, 2, 3]) self.assertAllclose(d.b, [10, 20, 30])
def test_extend_1(self): c = Comments() c2 = Comments(["apa:11"]) c.add_from_comment("!a: 10") self.assertEqual(c.fullcomments, ["a: 10"]) c.extend(c2) self.assertEqual(c.fullcomments, ["a: 10", "apa:11"])
def read_hdf5_handle(filehandle, **kw): if isinstance(filehandle, h5py.File): db = DataBlock() for k in filehandle: if "dimtype" not in filehandle[k].attrs: db[k] = getvar(filehandle, k) db.comments = Comments() return db else: raise IOError("filehandle should be a h5py File, is: %r" % filehandle)
self.assertTrue("Y" in out) class Test_yield_dim_consistent_datablocks(TestCase): def setUp(self): self.db = db = DataBlock() Sdims = (DimRep("freq", [1, 2]), DimRep("r", [1]), DimMatrix_i("i", 2), DimMatrix_j("j", 2)) db.S = hfarray( np.array([[11, 12], [21, 22]])[np.newaxis, np.newaxis, :, :] * np.array([[10], [20]])[..., np.newaxis, np.newaxis], dims=Sdims) db.V = hfarray([1.23], Sdims[1:2]) db.Y = hfarray([1.23], (DimRep("k", [1]), )) def test1(self): res = list( dset.yield_dim_consistent_datablocks( dset.convert_matrices_to_elements(self.db))) self.assertTrue(len(res) == 2) if __name__ == '__main__': d = DataBlock() d.comments = Comments(["Vgs=10", "Ig=10"]) fi = DimSweep("Freq[GHz]", 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()
def test_1(self): c = Comments() c.add_from_comment("!") self.assertEqual(c.fullcomments, [])
def setUp(self): self.comment = Comments(["Vgs[V] = -1 ", "Vds[V] = 5.3", "Ig[uA] = 0.3 ", "Id[mA] = 20 ", "P = 20 mW"])
def setUp(self): self.comment = Comments(["V1=10", "V2[V]=13", "V3 [V] = 14"])
def setUp(self): self.comment = Comments(["V1:10", "V2[V]:13", "V3 [V] : 14"])
def test_table3(self): c = Comments() x = c.table() self.assertEqual(x, [])