From 9bcc91c8d34e5c3d39f45da8d6c8f4afbe411c47 Mon Sep 17 00:00:00 2001 From: TimSangster Date: Thu, 20 Jun 2019 12:53:43 +0200 Subject: [PATCH 1/2] Update pythonwhat is_instance documentation --- pythonwhat/checks/check_object.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pythonwhat/checks/check_object.py b/pythonwhat/checks/check_object.py index a3890d02..371e8c23 100644 --- a/pythonwhat/checks/check_object.py +++ b/pythonwhat/checks/check_object.py @@ -204,7 +204,7 @@ def is_instance(state, inst, not_instance_msg=None): used to 'zoom in' on the object of interest. Args: - inst (class): The class that the object should have. + inst (str): The class that the object should have as a string. not_instance_msg (str): When specified, this overrides the automatically generated message in case the object does not have the expected class. state (State): The state that is passed in through the SCT chain (don't specify this). @@ -220,7 +220,7 @@ def is_instance(state, inst, not_instance_msg=None): # Verify the class of arr import numpy - Ex().check_object('arr').is_instance(numpy.ndarray) + Ex().check_object('arr').is_instance('numpy.ndarray') """ state.assert_is(["object_assignments"], "is_instance", ["check_object"]) From 9f81d7567aa2659d2a0d793009156cc8dbb37e9c Mon Sep 17 00:00:00 2001 From: TimSangster Date: Thu, 20 Jun 2019 16:40:13 +0200 Subject: [PATCH 2/2] Added "Recommended approach for testing train test splits" to glossary --- docs/glossary.rst | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/docs/glossary.rst b/docs/glossary.rst index 3633ae83..3b0782d8 100644 --- a/docs/glossary.rst +++ b/docs/glossary.rst @@ -225,6 +225,32 @@ Check Multiple Choice "That's a clown who likes burgers.", "Correct! Head over to the next exercise!"]) +Recommended approach for testing train test splits +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +.. code:: + + # solution + # Perform the train-test split + X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42) + + # sct + Ex().check_correct( + multi( + check_object("X_train").has_equal_value(), + check_object("X_test").has_equal_value(), + check_object("y_train").has_equal_value(), + check_object("y_test").has_equal_value() + ), + check_function("sklearn.model_selection.train_test_split").multi( + check_args(["arrays", 0]).has_equal_value("Did you correctly pass in the feature variable to `train_test_split()`?"), + check_args(["arrays", 1]).has_equal_value("Did you correctly pass in the target variable to `train_test_split()`?"), + check_args(["options", "test_size"]).has_equal_value("Did you specify the correct train test split?"), + check_args(["options", "random_state"]).has_equal_value("Don't change the `random_state` argument we set for you.") + ) + ) + + Check import ~~~~~~~~~~~~