本文整理汇总了Python中MA.choose方法的典型用法代码示例。如果您正苦于以下问题:Python MA.choose方法的具体用法?Python MA.choose怎么用?Python MA.choose使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MA
的用法示例。
在下文中一共展示了MA.choose方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testChoose
# 需要导入模块: import MA [as 别名]
# 或者: from MA import choose [as 别名]
def testChoose (self):
"Test the choose function."
assert eq (MA.choose (self.a, (5,4,3,2,1,0)), self.a[::-1])
assert eq (MA.choose ([[1,0], [0,1]], (66, [(1,2),(11,12)])),
[[1,66],[66,12]])
self.failUnlessRaises(ValueError, MA.choose, (0,1,2),([1,1,1],[2,2,2]))
示例2: agegrp
# 需要导入模块: import MA [as 别名]
# 或者: from MA import choose [as 别名]
def agegrp(age):
agrp = MA.choose(MA.greater_equal(age, 85), (age, -18.0))
agrp = MA.choose(MA.greater_equal(agrp, 80), (agrp, -17.0))
agrp = MA.choose(MA.greater_equal(agrp, 75), (agrp, -16.0))
agrp = MA.choose(MA.greater_equal(agrp, 70), (agrp, -15.0))
agrp = MA.choose(MA.greater_equal(agrp, 65), (agrp, -14.0))
agrp = MA.choose(MA.greater_equal(agrp, 60), (agrp, -13.0))
agrp = MA.choose(MA.greater_equal(agrp, 55), (agrp, -12.0))
agrp = MA.choose(MA.greater_equal(agrp, 50), (agrp, -11.0))
agrp = MA.choose(MA.greater_equal(agrp, 45), (agrp, -10.0))
agrp = MA.choose(MA.greater_equal(agrp, 40), (agrp, -9.0))
agrp = MA.choose(MA.greater_equal(agrp, 35), (agrp, -8.0))
agrp = MA.choose(MA.greater_equal(agrp, 30), (agrp, -7.0))
agrp = MA.choose(MA.greater_equal(agrp, 25), (agrp, -6.0))
agrp = MA.choose(MA.greater_equal(agrp, 20), (agrp, -5.0))
agrp = MA.choose(MA.greater_equal(agrp, 15), (agrp, -4.0))
agrp = MA.choose(MA.greater_equal(agrp, 10), (agrp, -3.0))
agrp = MA.choose(MA.greater_equal(agrp, 5), (agrp, -2.0))
agrp = MA.choose(MA.greater_equal(agrp, 0), (agrp, -1.0))
returnarray = -agrp.astype(MA.Int)
return returnarray