def test_fromrows(self): dlist = [ [1, 2, 3], [4, 5, 6], ] dt = np.dtype([('a', float), ('b', float), ('c', float)]) with pytest.raises(ValueError): tab = Table(dlist, dtype=dt) tab = Table.from_rows(dlist, dtype=dt) print(tab.dtype) print(tab.shape) print(tab) assert tab.h5loc == DEFAULT_H5LOC assert isinstance(tab, Table) tab = Table.from_rows(dlist, dtype=dt, h5loc='/foo') print(tab.dtype) print(tab.shape) print(tab) assert tab.h5loc == '/foo' assert isinstance(tab, Table) bad_dt = [('a', float), ('b', float), ('c', float), ('d', int)] with pytest.raises(ValueError): tab = Table.from_rows(dlist, dtype=bad_dt) print(tab.dtype) print(tab.shape) print(tab)
def test_fromrows(self): dlist = [ [1, 2, 3], [4, 5, 6], ] dt = np.dtype([("a", float), ("b", float), ("c", float)]) with pytest.raises(ValueError): tab = Table(dlist, dtype=dt) tab = Table.from_rows(dlist, dtype=dt) print(tab.dtype) print(tab.shape) print(tab) assert tab.h5loc == DEFAULT_H5LOC assert isinstance(tab, Table) tab = Table.from_rows(dlist, dtype=dt, h5loc="/foo") print(tab.dtype) print(tab.shape) print(tab) assert tab.h5loc == "/foo" assert isinstance(tab, Table) bad_dt = [("a", float), ("b", float), ("c", float), ("d", int)] with pytest.raises(ValueError): tab = Table.from_rows(dlist, dtype=bad_dt) print(tab.dtype) print(tab.shape) print(tab)
def test_from_rows_dim(self): t = Table.from_rows([[1, 2], [3.0, 4], [5, 6]], colnames=['a', 'b']) assert t.shape == (3, )
def test_from_rows_with_colnames_upcasts(self): t = Table.from_rows([[1, 2], [3.0, 4], [5, 6]], colnames=['a', 'b']) assert t.dtype == np.dtype([('a', float), ('b', float)])
def test_from_rows_with_colnames(self): t = Table.from_rows([[1, 2], [3, 4], [5, 6]], colnames=['a', 'b']) assert t.dtype == np.dtype([('a', int), ('b', int)]) assert np.allclose([1, 3, 5], t.a) assert np.allclose([2, 4, 6], t.b)
def test_from_rows_dim(self): t = Table.from_rows([[1, 2], [3.0, 4], [5, 6]], colnames=["a", "b"]) assert t.shape == (3, )
def test_from_rows_with_colnames_upcasts(self): t = Table.from_rows([[1, 2], [3.0, 4], [5, 6]], colnames=["a", "b"]) assert t.dtype == np.dtype([("a", float), ("b", float)])
def test_from_rows_with_colnames(self): t = Table.from_rows([[1, 2], [3, 4], [5, 6]], colnames=["a", "b"]) assert t.dtype == np.dtype([("a", int), ("b", int)]) assert np.allclose([1, 3, 5], t.a) assert np.allclose([2, 4, 6], t.b)