def setUp(self): self.a = aobj.hfarray([1, 2, 3], dims=(ds.DiagAxis("f", 3),)) dims = (ds.DiagAxis("f", 3), ds.DiagAxis("p", 3),) self.b = aobj.hfarray([[1, 2, 3], [10, 20, 30], [100, 200, 300]], dims=dims) dims = (ds.DimSweep("f", 2), ds.DimSweep("Vg", 3), ds.DimRep("rep", 4)) self.c = aobj.hfarray(np.zeros((2, 3, 4)), dims=dims) dims = (ds.DimSweep("f", 2), ds.DimSweep("Vg", 3), ds.DimRep("rep", 4), ds.DimMatrix_i("i", 5), ds.DimMatrix_j("j", 5),) self.d = aobj.hfarray(np.zeros((2, 3, 4, 5, 5)), dims=dims)
def test_init_2(self): a = np.array([[1, 2, 3]] * 4) A = aobj.hfarray(a) self.assertEqual(A.dims, (ds.DimSweep("freq", 4), ds.DimRep("rep", 3))) self.assertAllclose(a, A)
def test_4(self): d = aobj.remove_rep(self.d) self.assertAllclose(d, 0) dims = (ds.DimSweep("f", 2), ds.DimRep("AllReps", 12), ds.DimMatrix_i("i", 5), ds.DimMatrix_j("j", 5),) self.assertEqual(d.dims, dims)
def test_3(self): c = aobj.remove_rep(self.c) self.assertAllclose(c, 0) dims = (ds.DimSweep("f", 2), ds.DimSweep("Vg", 3), ds.DimRep("AllReps", 4)) self.assertEqual(c.dims, dims)
def test_3(self): a = aobj.remove_tail(self.d) self.assertAllclose(a, 0) dims = (ds.DimSweep("f", 2), ds.DimRep("Tail", 12), ds.DimMatrix_i("i", 5), ds.DimMatrix_j("j", 5),) self.assertEqual(a.dims, dims)
def test_2(self): a = aobj.remove_tail(self.c) self.assertAllclose(a, 0) self.assertEqual(a.dims, (ds.DimSweep("f", 2), ds.DimRep("Tail", 12)))
def test_1(self): a = aobj.remove_tail(self.a) self.assertAllclose(a, np.array(self.a)[:, newaxis]) self.assertEqual(a.dims, (ds.DiagAxis("f", 3), ds.DimRep("Tail", 1)))