def test_vDF_magic(self, titanic_vd): assert (str(titanic_vd["name"]._in( ["Madison", "Ashley", None])) == "(\"name\") IN ('Madison', 'Ashley', NULL)") assert str(titanic_vd["age"]._between( 1, 4)) == '("age") BETWEEN (1) AND (4)' assert str(titanic_vd["age"]._as("age2")) == '("age") AS age2' assert str(titanic_vd["age"]._distinct()) == 'DISTINCT ("age")' assert (str( st.sum(titanic_vd["age"])._over( by=[titanic_vd["pclass"], titanic_vd["sex"]], order_by=[titanic_vd["fare"]], ) ) == 'SUM("age") OVER (PARTITION BY "pclass", "sex" ORDER BY "fare")') assert str(abs(titanic_vd["age"])) == 'ABS("age")' assert str(ceil(titanic_vd["age"])) == 'CEIL("age")' assert str(floor(titanic_vd["age"])) == 'FLOOR("age")' assert str(round(titanic_vd["age"], 2)) == 'ROUND("age", 2)' assert str(-titanic_vd["age"]) == '-("age")' assert str(+titanic_vd["age"]) == '+("age")' assert str(titanic_vd["age"] % 2) == 'MOD("age", 2)' assert str(2 % titanic_vd["age"]) == 'MOD(2, "age")' assert str(titanic_vd["age"]**2) == 'POWER("age", 2)' assert str(2**titanic_vd["age"]) == 'POWER(2, "age")' assert str(titanic_vd["age"] + 3) == '("age") + (3)' assert str(3 + titanic_vd["age"]) == '(3) + ("age")' assert str(titanic_vd["age"] - 3) == '("age") - (3)' assert str(3 - titanic_vd["age"]) == '(3) - ("age")' assert str(titanic_vd["age"] * 3) == '("age") * (3)' assert str(3 * titanic_vd["age"]) == '(3) * ("age")' assert str(titanic_vd["age"] // 3) == '("age") // (3)' assert str(3 // titanic_vd["age"]) == '(3) // ("age")' assert str(titanic_vd["age"] > 3) == '("age") > (3)' assert str(3 > titanic_vd["age"]) == '("age") < (3)' assert str(titanic_vd["age"] >= 3) == '("age") >= (3)' assert str(3 >= titanic_vd["age"]) == '("age") <= (3)' assert str(titanic_vd["age"] < 3) == '("age") < (3)' assert str(3 < titanic_vd["age"]) == '("age") > (3)' assert str(titanic_vd["age"] <= 3) == '("age") <= (3)' assert str(3 <= titanic_vd["age"]) == '("age") >= (3)' assert (str((3 >= titanic_vd["age"]) & (titanic_vd["age"] <= 50)) == '(("age") <= (3)) AND (("age") <= (50))') assert (str((3 >= titanic_vd["age"]) | (titanic_vd["age"] <= 50)) == '(("age") <= (3)) OR (("age") <= (50))') assert str("Mr " + titanic_vd["name"]) == "('Mr ') || (\"name\")" assert str(titanic_vd["name"] + " .") == "(\"name\") || (' .')" assert str(3 * titanic_vd["name"]) == 'REPEAT("name", 3)' assert str(titanic_vd["name"] * 3) == 'REPEAT("name", 3)' assert str(titanic_vd["age"] == 3) == '("age") = (3)' assert str(3 == titanic_vd["age"]) == '("age") = (3)' assert str(titanic_vd["age"] != 3) == '("age") != (3)' assert str(None != titanic_vd["age"]) == '("age") IS NOT NULL' assert titanic_vd["fare"][0] >= 0 assert titanic_vd[["fare"]][0][0] >= 0 assert titanic_vd[titanic_vd["fare"] > 500].shape()[0] == 4 assert titanic_vd[titanic_vd["fare"] < 500].shape()[0] == 1229 assert titanic_vd[titanic_vd["fare"] * 4 + 2 < 500].shape()[0] == 1167 assert titanic_vd[titanic_vd["fare"] / 4 - 2 < 500].shape()[0] == 1233
def test_sum(self, titanic_vd): assert str(st.sum(titanic_vd["age"])) == 'SUM("age")'