本文整理汇总了Python中shake_event.ShakeEvent.sortedImpactedCities方法的典型用法代码示例。如果您正苦于以下问题:Python ShakeEvent.sortedImpactedCities方法的具体用法?Python ShakeEvent.sortedImpactedCities怎么用?Python ShakeEvent.sortedImpactedCities使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类shake_event.ShakeEvent
的用法示例。
在下文中一共展示了ShakeEvent.sortedImpactedCities方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testSortedImpactedCities
# 需要导入模块: from shake_event import ShakeEvent [as 别名]
# 或者: from shake_event.ShakeEvent import sortedImpactedCities [as 别名]
def testSortedImpactedCities(self):
"""Test getting impacted cities sorted by mmi then population."""
myShakeId = '20120726022003'
myShakeEvent = ShakeEvent(myShakeId)
myTable = myShakeEvent.sortedImpactedCities()
myExpectedResult = [
{'dir_from': 13.119078636169434, 'dir_to': -166.88092041015625,
'roman': 'II', 'dist_to': 3.036229133605957, 'mmi-int': 2.0,
'name': 'Manado', 'mmi': 1.809999942779541, 'id': 207,
'population': 451893},
{'dir_from': -61.620426177978516, 'dir_to': 118.37957000732422,
'roman': 'II', 'dist_to': 2.4977917671203613, 'mmi-int': 2.0,
'name': 'Gorontalo', 'mmi': 2.25, 'id': 282,
'population': 144195},
{'dir_from': -114.04046630859375, 'dir_to': 65.95953369140625,
'roman': 'II', 'dist_to': 3.3138768672943115, 'mmi-int': 2.0,
'name': 'Luwuk', 'mmi': 1.5299999713897705, 'id': 215,
'population': 47778},
{'dir_from': 16.94407844543457, 'dir_to': -163.05592346191406,
'roman': 'II', 'dist_to': 2.504295825958252, 'mmi-int': 2.0,
'name': 'Tondano', 'mmi': 1.909999966621399, 'id': 57,
'population': 33317},
{'dir_from': 14.14267635345459, 'dir_to': -165.85733032226562,
'roman': 'II', 'dist_to': 2.5372657775878906, 'mmi-int': 2.0,
'name': 'Tomohon', 'mmi': 1.690000057220459, 'id': 58,
'population': 27624}]
myMessage = 'Got:\n%s\nExpected:\n%s\n' % (myTable, myExpectedResult)
assert myTable == myExpectedResult, myMessage
示例2: testSortedImpactedCities
# 需要导入模块: from shake_event import ShakeEvent [as 别名]
# 或者: from shake_event.ShakeEvent import sortedImpactedCities [as 别名]
def testSortedImpactedCities(self):
"""Test getting impacted cities sorted by mmi then population."""
myShakeId = '20120726022003'
myShakeEvent = ShakeEvent(myShakeId)
myTable = myShakeEvent.sortedImpactedCities()
myFilePath = unique_filename(
prefix='testSortedImpactedCities',
suffix='.txt',
dir=temp_dir('test'))
myFile = file(myFilePath, 'wt')
myFile.writelines(str(myTable))
myFile.close()
myTable = str(myTable).replace(', \'', ',\n\'')
myTable += '\n'
myFixturePath = os.path.join(
dataDir(), 'tests', 'testSortedImpactedCities.txt')
myFile = file(myFixturePath, 'rt')
myExpectedString = myFile.read()
myFile.close()
myExpectedString = myExpectedString.replace(', \'', ',\n\'')
self.maxDiff = None
self.assertEqual(myExpectedString, myTable)