コード例 #1
0
ファイル: test_dataclasses.py プロジェクト: tamasgal/km3pipe
 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)
コード例 #2
0
 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)
コード例 #3
0
ファイル: test_dataclasses.py プロジェクト: tamasgal/km3pipe
 def test_from_rows_dim(self):
     t = Table.from_rows([[1, 2], [3.0, 4], [5, 6]], colnames=['a', 'b'])
     assert t.shape == (3, )
コード例 #4
0
ファイル: test_dataclasses.py プロジェクト: tamasgal/km3pipe
 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)])
コード例 #5
0
ファイル: test_dataclasses.py プロジェクト: tamasgal/km3pipe
 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)
コード例 #6
0
 def test_from_rows_dim(self):
     t = Table.from_rows([[1, 2], [3.0, 4], [5, 6]], colnames=["a", "b"])
     assert t.shape == (3, )
コード例 #7
0
 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)])
コード例 #8
0
 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)