本文整理汇总了Python中shake_event.ShakeEvent.bearingToCardinal方法的典型用法代码示例。如果您正苦于以下问题:Python ShakeEvent.bearingToCardinal方法的具体用法?Python ShakeEvent.bearingToCardinal怎么用?Python ShakeEvent.bearingToCardinal使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类shake_event.ShakeEvent
的用法示例。
在下文中一共展示了ShakeEvent.bearingToCardinal方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testBearingToCardinal
# 需要导入模块: from shake_event import ShakeEvent [as 别名]
# 或者: from shake_event.ShakeEvent import bearingToCardinal [as 别名]
def testBearingToCardinal(self):
"""Test we can convert a bearing to a cardinal direction."""
myShakeId = '20120726022003'
myShakeEvent = ShakeEvent(myShakeId)
# Ints should work
myExpectedResult = 'SSE'
myResult = myShakeEvent.bearingToCardinal(160)
myMessage = ('Got:\n%s\nExpected:\n%s\n' %
(myResult, myExpectedResult))
assert myResult == myExpectedResult, myMessage
# Floats should work
myExpectedResult = 'SW'
myResult = myShakeEvent.bearingToCardinal(225.4)
myMessage = ('Got:\n%s\nExpected:\n%s\n' %
(myResult, myExpectedResult))
assert myResult == myExpectedResult, myMessage
# non numeric data as input should return None
myExpectedResult = None
myResult = myShakeEvent.bearingToCardinal('foo')
myMessage = ('Got:\n%s\nExpected:\n%s\n' %
(myResult, myExpectedResult))
assert myResult == myExpectedResult, myMessage