本文整理汇总了Python中obspy.core.event.Catalog.extend方法的典型用法代码示例。如果您正苦于以下问题:Python Catalog.extend方法的具体用法?Python Catalog.extend怎么用?Python Catalog.extend使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类obspy.core.event.Catalog
的用法示例。
在下文中一共展示了Catalog.extend方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_extend
# 需要导入模块: from obspy.core.event import Catalog [as 别名]
# 或者: from obspy.core.event.Catalog import extend [as 别名]
def test_extend(self):
"""
Tests the extend method of the Catalog object.
"""
# 1 - create catalog and extend it with list of events
catalog = Catalog()
event1 = Event()
event2 = Event()
self.assertEqual(len(catalog), 0)
catalog.extend([event1, event2])
self.assertEqual(len(catalog), 2)
self.assertEqual(catalog.events, [event1, event2])
# 2 - extend it with other catalog
event3 = Event()
event4 = Event()
catalog2 = Catalog([event3, event4])
self.assertEqual(len(catalog), 2)
catalog.extend(catalog2)
self.assertEqual(len(catalog), 4)
self.assertEqual(catalog.events, [event1, event2, event3, event4])
# adding objects other as Catalog or list should fails
self.assertRaises(TypeError, catalog.extend, str)
self.assertRaises(TypeError, catalog.extend, event1)
self.assertRaises(TypeError, catalog.extend, (event1, event2))