本文整理汇总了Python中km3pipe.dataclasses.Table.from_rows方法的典型用法代码示例。如果您正苦于以下问题:Python Table.from_rows方法的具体用法?Python Table.from_rows怎么用?Python Table.from_rows使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类km3pipe.dataclasses.Table
的用法示例。
在下文中一共展示了Table.from_rows方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_fromrows
# 需要导入模块: from km3pipe.dataclasses import Table [as 别名]
# 或者: from km3pipe.dataclasses.Table import from_rows [as 别名]
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: test_from_rows_with_colnames_upcasts
# 需要导入模块: from km3pipe.dataclasses import Table [as 别名]
# 或者: from km3pipe.dataclasses.Table import from_rows [as 别名]
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)])
示例3: test_from_rows_dim
# 需要导入模块: from km3pipe.dataclasses import Table [as 别名]
# 或者: from km3pipe.dataclasses.Table import from_rows [as 别名]
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: test_from_rows_with_colnames
# 需要导入模块: from km3pipe.dataclasses import Table [as 别名]
# 或者: from km3pipe.dataclasses.Table import from_rows [as 别名]
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)