本文整理汇总了Python中km3pipe.dataclasses.Table.copy方法的典型用法代码示例。如果您正苦于以下问题:Python Table.copy方法的具体用法?Python Table.copy怎么用?Python Table.copy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类km3pipe.dataclasses.Table
的用法示例。
在下文中一共展示了Table.copy方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_apply_without_affecting_primary_hit_table
# 需要导入模块: from km3pipe.dataclasses import Table [as 别名]
# 或者: from km3pipe.dataclasses.Table import copy [as 别名]
def test_apply_without_affecting_primary_hit_table(self):
calib = Calibration(filename=DETX_FILENAME)
hits = Table({'pmt_id': [1, 2, 1], 'time': [10.1, 11.2, 12.3]})
hits_compare = hits.copy()
calib.apply(hits)
for t_primary, t_calib in zip(hits_compare, hits):
self.assertAlmostEqual(t_primary, t_calib)
示例2: TestTableFancaAttributes
# 需要导入模块: from km3pipe.dataclasses import Table [as 别名]
# 或者: from km3pipe.dataclasses.Table import copy [as 别名]
class TestTableFancaAttributes(TestCase):
def setUp(self):
self.arr_bare = Table({
'a': [1, 2, 3],
'b': [3, 4, 5],
})
self.arr_wpos = Table({
'a': [1, 2, 3],
'b': [3, 4, 5],
'pos_x': [10, 20, 30],
'pos_y': [40, 50, 60],
'pos_z': [70, 80, 90],
'dir_x': [10.0, 20.0, 30.0],
'dir_y': [40.0, 50.0, 60.0],
'dir_z': [70.0, 80.0, 90.0],
})
def test_pos_getter(self):
tab = Table({
'pos_x': [1, 2, 3],
'pos_y': [4, 5, 6],
'pos_z': [7, 8, 9]
})
assert np.allclose([[1, 4, 7], [2, 5, 8], [3, 6, 9]], tab.pos)
def test_pos_getter_for_single_entry(self):
tab = Table({
'pos_x': [1, 2, 3],
'pos_y': [4, 5, 6],
'pos_z': [7, 8, 9]
})
assert np.allclose([[2, 5, 8]], tab.pos[1])
def test_dir_getter(self):
tab = Table({
'dir_x': [1, 2, 3],
'dir_y': [4, 5, 6],
'dir_z': [7, 8, 9]
})
assert np.allclose([[1, 4, 7], [2, 5, 8], [3, 6, 9]], tab.dir)
def test_dir_getter_for_single_entry(self):
tab = Table({
'dir_x': [1, 2, 3],
'dir_y': [4, 5, 6],
'dir_z': [7, 8, 9]
})
assert np.allclose([[2, 5, 8]], tab.dir[1])
def test_dir_setter(self):
tab = Table({
'dir_x': [1, 0, 0],
'dir_y': [0, 1, 0],
'dir_z': [0, 0, 1]
})
new_dir = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]
tab.dir = new_dir
assert np.allclose(new_dir, tab.dir)
def test_pos_setter(self):
tab = Table({
'pos_x': [1, 0, 0],
'pos_y': [0, 1, 0],
'pos_z': [0, 0, 1]
})
new_pos = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]
tab.pos = new_pos
assert np.allclose(new_pos, tab.pos)
def test_same_shape_pos(self):
with pytest.raises(AttributeError):
p = self.arr_bare.pos
p = self.arr_wpos.pos
self.arr_wpos.pos = p
assert p is not None
# assert p.shape[1] == 3
with pytest.raises(ValueError):
self.arr_bare.dir = p
def test_same_shape_dir(self):
with pytest.raises(AttributeError):
p = self.arr_bare.dir
p = self.arr_wpos.dir
self.arr_wpos.dir = p
assert p is not None
# assert p.shape[1] == 3
a2 = self.arr_bare.copy()
with pytest.raises(ValueError):
self.arr_bare.dir = p
def test_phi(self):
tab = Table({
'dir_x': [1, 0, 0],
'dir_y': [0, 1, 0],
'dir_z': [0, 0, 1]
})
p = tab.phi
assert p is not None
def test_phi(self):
#.........这里部分代码省略.........