def test_fromrecords_wmask(self): "Tests construction from records w/ mask." (mrec, nrec, ddtype) = self.data # _mrec = fromrecords(nrec.tolist(), dtype=ddtype, mask=[ 0, 1, 0, ]) assert_equal_records(_mrec._data, mrec._data) assert_equal(_mrec._mask.tolist(), [(0, 0, 0), (1, 1, 1), (0, 0, 0)]) # _mrec = fromrecords(nrec.tolist(), dtype=ddtype, mask=True) assert_equal_records(_mrec._data, mrec._data) assert_equal(_mrec._mask.tolist(), [(1, 1, 1), (1, 1, 1), (1, 1, 1)]) # _mrec = fromrecords(nrec.tolist(), dtype=ddtype, mask=mrec._mask) assert_equal_records(_mrec._data, mrec._data) assert_equal(_mrec._mask.tolist(), mrec._mask.tolist()) # _mrec = fromrecords(nrec.tolist(), dtype=ddtype, mask=mrec._mask.tolist()) assert_equal_records(_mrec._data, mrec._data) assert_equal(_mrec._mask.tolist(), mrec._mask.tolist())
def test_fromrecords(self): "Test construction from records." (mrec, nrec, ddtype) = self.data #...... palist = [(1, 'abc', 3.7000002861022949, 0), (2, 'xy', 6.6999998092651367, 1), (0, ' ', 0.40000000596046448, 0)] pa = recfromrecords(palist, names='c1, c2, c3, c4') mpa = fromrecords(palist, names='c1, c2, c3, c4') assert_equal_records(pa, mpa) #..... _mrec = fromrecords(nrec) assert_equal(_mrec.dtype, mrec.dtype) for field in _mrec.dtype.names: assert_equal(getattr(_mrec, field), getattr(mrec._data, field)) # _mrec = fromrecords(nrec.tolist(), names='c1,c2,c3') assert_equal(_mrec.dtype, [('c1', int), ('c2', float), ('c3', '|S5')]) for (f, n) in zip(('c1', 'c2', 'c3'), ('a', 'b', 'c')): assert_equal(getattr(_mrec, f), getattr(mrec._data, n)) # _mrec = fromrecords(mrec) assert_equal(_mrec.dtype, mrec.dtype) assert_equal_records(_mrec._data, mrec.filled()) assert_equal_records(_mrec._mask, mrec._mask)
def test_fromrecords(self): # Test construction from records. (mrec, nrec, ddtype) = self.data #...... palist = [(1, 'abc', 3.7000002861022949, 0), (2, 'xy', 6.6999998092651367, 1), (0, ' ', 0.40000000596046448, 0)] pa = recfromrecords(palist, names='c1, c2, c3, c4') mpa = fromrecords(palist, names='c1, c2, c3, c4') assert_equal_records(pa, mpa) #..... _mrec = fromrecords(nrec) assert_equal(_mrec.dtype, mrec.dtype) for field in _mrec.dtype.names: assert_equal(getattr(_mrec, field), getattr(mrec._data, field)) _mrec = fromrecords(nrec.tolist(), names='c1,c2,c3') assert_equal(_mrec.dtype, [('c1', int), ('c2', float), ('c3', '|S5')]) for (f, n) in zip(('c1', 'c2', 'c3'), ('a', 'b', 'c')): assert_equal(getattr(_mrec, f), getattr(mrec._data, n)) _mrec = fromrecords(mrec) assert_equal(_mrec.dtype, mrec.dtype) assert_equal_records(_mrec._data, mrec.filled()) assert_equal_records(_mrec._mask, mrec._mask)
def test_fromrecords(self): # Test construction from records. (mrec, nrec, ddtype) = self.data # ...... palist = [ (1, "abc", 3.7000002861022949, 0), (2, "xy", 6.6999998092651367, 1), (0, " ", 0.40000000596046448, 0), ] pa = recfromrecords(palist, names="c1, c2, c3, c4") mpa = fromrecords(palist, names="c1, c2, c3, c4") assert_equal_records(pa, mpa) # ..... _mrec = fromrecords(nrec) assert_equal(_mrec.dtype, mrec.dtype) for field in _mrec.dtype.names: assert_equal(getattr(_mrec, field), getattr(mrec._data, field)) _mrec = fromrecords(nrec.tolist(), names="c1,c2,c3") assert_equal(_mrec.dtype, [("c1", int), ("c2", float), ("c3", "|S5")]) for (f, n) in zip(("c1", "c2", "c3"), ("a", "b", "c")): assert_equal(getattr(_mrec, f), getattr(mrec._data, n)) _mrec = fromrecords(mrec) assert_equal(_mrec.dtype, mrec.dtype) assert_equal_records(_mrec._data, mrec.filled()) assert_equal_records(_mrec._mask, mrec._mask)
def test_fromrecords_wmask(self): # Tests construction from records w/ mask. (mrec, nrec, ddtype) = self.data # _mrec = fromrecords(nrec.tolist(), dtype=ddtype, mask=[0, 1, 0]) assert_equal_records(_mrec._data, mrec._data) assert_equal(_mrec._mask.tolist(), [(0, 0, 0), (1, 1, 1), (0, 0, 0)]) # _mrec = fromrecords(nrec.tolist(), dtype=ddtype, mask=True) assert_equal_records(_mrec._data, mrec._data) assert_equal(_mrec._mask.tolist(), [(1, 1, 1), (1, 1, 1), (1, 1, 1)]) # _mrec = fromrecords(nrec.tolist(), dtype=ddtype, mask=mrec._mask) assert_equal_records(_mrec._data, mrec._data) assert_equal(_mrec._mask.tolist(), mrec._mask.tolist()) # _mrec = fromrecords(nrec.tolist(), dtype=ddtype, mask=mrec._mask.tolist()) assert_equal_records(_mrec._data, mrec._data) assert_equal(_mrec._mask.tolist(), mrec._mask.tolist())
def test_fromrecords(self): # Test construction from records. (mrec, nrec, ddtype) = self.data # ...... palist = [(1, "abc", 3.7000002861022949, 0), (2, "xy", 6.6999998092651367, 1), (0, " ", 0.40000000596046448, 0)] pa = recfromrecords(palist, names="c1, c2, c3, c4") mpa = fromrecords(palist, names="c1, c2, c3, c4") assert_equal_records(pa, mpa) # ..... _mrec = fromrecords(nrec) assert_equal(_mrec.dtype, mrec.dtype) for field in _mrec.dtype.names: assert_equal(getattr(_mrec, field), getattr(mrec._data, field)) # _mrec = fromrecords(nrec.tolist(), names="c1,c2,c3") assert_equal(_mrec.dtype, [("c1", int), ("c2", float), ("c3", "|S5")]) for (f, n) in zip(("c1", "c2", "c3"), ("a", "b", "c")): assert_equal(getattr(_mrec, f), getattr(mrec._data, n)) # _mrec = fromrecords(mrec) assert_equal(_mrec.dtype, mrec.dtype) assert_equal_records(_mrec._data, mrec.filled()) assert_equal_records(_mrec._mask, mrec._mask)