def test_fromrecords(self): "Test from recarray." [d, m, mrec] = self.data nrec = N.core.records.fromarrays(N.r_[[d,d[::-1]]]) mrecfr = fromrecords(nrec.tolist()) assert_equal(mrecfr.f0, mrec.f0) assert_equal(mrecfr.dtype, mrec.dtype) #.................... mrecfr = fromrecords(nrec) assert_equal(mrecfr.f0, mrec.f0) assert_equal(mrecfr.dtype, mrec.dtype) #.................... tmp = mrec[::-1] #.tolist() mrecfr = fromrecords(tmp) assert_equal(mrecfr.f0, mrec.f0[::-1])
def test_fromrecords(self): "Test from recarray." [d, m, mrec] = self.data nrec = N.core.records.fromarrays(N.r_[[d,d[::-1]]], dtype=[('a',N.float_),('b',N.float_)]) #.................... mrecfr = fromrecords(nrec) assert_equal(mrecfr.a, mrec.a) assert_equal(mrecfr.dtype, mrec.dtype) #.................... tmp = mrec[::-1] #.tolist() mrecfr = fromrecords(tmp) assert_equal(mrecfr.a, mrec.a[::-1]) #.................... mrecfr = fromrecords(nrec.tolist(), names=nrec.dtype.names) assert_equal(mrecfr.a, mrec.a) assert_equal(mrecfr.dtype, mrec.dtype)