예제 #1
0
    def setUp(self):
        self.adims = (aobj.DimSweep("f", 1),
                      aobj.DimMatrix_i("i", 2),
                      aobj.DimMatrix_j("j", 2))
        self.a = aobj.hfarray([[[0, 0j], [0, 0]]], dims=self.adims)
        self.bdims = (aobj.DimSweep("f", 10),
                      aobj.DimMatrix_i("i", 2),
                      aobj.DimMatrix_j("j", 2))
        self.b = aobj.hfarray(np.array([[[1, 2 + 0j], [3, 4]]]) +
                              np.arange(10)[:, newaxis, newaxis],
                              dims=self.bdims)

        self.c, = aobj.make_same_dims_list([random_value_array(4, 5)])
        self.cdims = self.c.dims
        self.ddims = self.bdims
        self.d = aobj.hfarray(np.array([[[1, 2], [3, 4]]]) +
                              np.arange(10)[:, newaxis, newaxis],
                              dims=self.ddims)

        self.i1 = i1 = aobj.DimSweep("i1", 1)
        self.i2 = i2 = aobj.DimSweep("i2", 1)
        self.i3 = i3 = aobj.DimSweep("i3", 1)
        self.i4 = i4 = aobj.DimSweep("i4", 1)
        self.i5 = i5 = aobj.DimSweep("i5", 1)
        self.fi = fi = aobj.DimSweep("f", 2),
        self.gi = gi = aobj.DimSweep("g", 3),

        self.e = aobj.hfarray(np.zeros((1, 2, 3)), dims=(i1, fi, gi))
        self.f = aobj.hfarray(np.zeros((2, 3, 1)), dims=(fi, gi, i1))
        self.g = aobj.hfarray(np.zeros((1, 2, 3, 1)), dims=(i2, fi, gi, i1))
        dims = (i2, fi, i3, gi, i1)
        self.h = aobj.hfarray(np.zeros((1, 2, 1, 3, 1)), dims=dims)
        dims = (i4, i5)
예제 #2
0
 def test_3(self):
     v, = aobj.make_same_dims_list([random_value_array(4, 5)])
     a = np.array(v)
     facit = np.sqrt((abs(a) ** 2).sum(1))
     res = v.rss(1)
     self.assertAllclose(res, facit)