def test_method_2(): code = "df[df.b == 'x'].a.sum()" s = setup_state(sol_code = code, stu_code = code, pec = "import pandas as pd; df = pd.DataFrame({'a': [1, 2, 3], 'b': ['x', 'x', 'y']})") helper.passes(s.check_function('df.a.sum', signature = False)) from pythonwhat.signatures import sig_from_obj import pandas as pd helper.passes(s.check_function('df.a.sum', signature = sig_from_obj(pd.Series.sum)))
def test_method_1(): code = "df.groupby('b').sum()" s = setup_state(sol_code = code, stu_code = code, pec = "import pandas as pd; df = pd.DataFrame({'a': [1, 2, 3], 'b': ['x', 'x', 'y']})") helper.passes(s.check_function('df.groupby').check_args(0).has_equal_value()) helper.passes(s.check_function('df.groupby.sum', signature = False)) from pythonwhat.signatures import sig_from_obj import pandas as pd helper.passes(s.check_function('df.groupby.sum', signature = sig_from_obj(pd.Series.sum)))
def test_method_2(): code = "print('a')" s = setup_state( sol_code=code, stu_code=code, pec="", ) helper.passes(s.check_function("print", signature=False)) from pythonwhat.signatures import sig_from_obj helper.passes(s.check_function("print", signature=sig_from_obj('print')))