def testIfThenElse(): t = Table(["a", "b", "c"], [str, int, int], ["%s", "%d", "%d"],[]) t.rows.append(["0", 1, 2]) t.rows.append([None, 2, 1]) t._print() t.addColumn("x", (t.a.isNotNone()).thenElse(t.b, t.c)) assert t.getColNames()==["a", "b", "c", "x"] print t._print() t.addColumn("y", (t.a.isNotNone()).thenElse("ok", "not ok")) t._print() assert t.y.values == ["ok", "not ok"]
def testIfThenElse(): t = Table(["a", "b", "c"], [str, int, int], ["%s", "%d", "%d"], []) t.rows.append(["0", 1, 2]) t.rows.append([None, 2, 1]) t._print() t.addColumn("x", (t.a.isNotNone()).thenElse(t.b, t.c)) assert t.getColNames() == ["a", "b", "c", "x"] print t._print() t.addColumn("y", (t.a.isNotNone()).thenElse("ok", "not ok")) t._print() assert t.y.values == ["ok", "not ok"]