datacamp / pythonwhat

Verify Python code submissions and auto-generate meaningful feedback messages.
http://pythonwhat.readthedocs.io/
GNU Affero General Public License v3.0
67 stars 31 forks source link

test_function_v2 #65

Closed hugobowne closed 7 years ago

hugobowne commented 7 years ago

Hi!

I have been playing around with test_function_v2() and I like it.

There are a couple of issues I have that we should discuss before I can really use it. i'm not entirely comfortable with the feedback messages that it provides:

E.g. it seems to always mention the keyword in question. See this:

screenshot 2016-08-24 15 34 31

course: https://campus.datacamp.com/courses/1533/3850?ex=5 repo: https://github.com/datacamp/HBA-python-problem-playground/blob/master/chapter1.md

The student may not have known the keyword file even existed. Could it provide i) a similar message as test_function in the case that the student uses a positional argument and ii) a different message if they use the keyword?

Also, will it be possible for an SCT to accept ONLY positional or ONLY keyword args? Apologies if this exists and I missed it

Another issue is that the SCT writer needs to write out explicitly ALL the arguments to be tested. It would be easier if it were like test_function(), in that it tests all those used in the solution code.

I am still coming to terms with test_function_v2. There are many subtleties in figuring out how to instruct students in this type of pedagogy.

Until now, I have been relying on my interns primarily for SCTs and have now realized that I need to get down'n'dirty w/ pythonwhat. Looking forward to it but wanted to let you know that other things may crop up

filipsch commented 7 years ago

@hugobowne

filipsch commented 7 years ago

@hugobowne Can you give your thoughts on this thing? The longer I wait with improving test_function_v2(), the longer there will be two "test_function code bases" that I have to maintain and support. And the longer it will take to switch from one system to the other. I'd like to have a clear, unambiguous interface for testing function calls at some point.

hugobowne commented 7 years ago

@filipsch I appreciate your patience with this. This week I am spending a lot of time with pythonwhat and will try my hand at working with both test_function() and test_function_v2() a great deal. I'll let you know how I go by EOW. That cool?

hugobowne commented 7 years ago

@filipsch i'll get onto this when the new backend is rolled out

filipsch commented 7 years ago

@hugobowne I suggest I provide another argument, named, that you can pass a list of boolean values, with the same length as the parameters you're specifying. If it's specified, it overrides the default behavior of mentioning the parameter name if it is possible to mention it by it's name.

Say, for example, you're testing

import pandas as pd
pd.DataFrame({'a': [1, 2, 3], 'b': [4, 5, 6]})

But the student did:

import pandas as pd
pd.DataFrame({'a': [10, 11, 12], 'b': [13, 14, 15]})

Depending on the SCT, you get different feedback:

test_function_v2("pandas.DataFrame", params = ["data"])
# message: Did you call `pd.DataFrame()` with the correct arguments? The argument you specified for `data` seems to be incorrect.
test_function_v2("pandas.DataFrame", params = ["data"], named = [True])
# message: Did you call `pd.DataFrame()` with the correct arguments? The argument you specified for `data` seems to be incorrect.
test_function_v2("pandas.DataFrame", params = ["data"], named = [False])
# message: Did you call `pd.DataFrame()` with the correct arguments? The first argument seems incorrect.
hugobowne commented 7 years ago

@filipsch my initial reaction is that I like this. Let me know about it. Due to delays, I will be getting to all of this next week and have my thoughts together by the DC retreat: is that ok?

filipsch commented 7 years ago

So I'll wait with implementing this, right?

hugobowne commented 7 years ago

I don't have enough experience yet with test_function_v2() to know what is a good idea so I think so, yes, wait.

machow commented 7 years ago

Closing, as this can be done in pythonwhat v2 using,

Ex().check_function('pandas.DataFrame', 0, signature=False).check_args(0).has_equal_value()

which will get a message like, "Check the first argument of the first function call for pandas.DataFrame".