I see that my submission has been graded as having an error where as all tests passed during the exercise.
The error also seems incorrect as the function is supposed to return a float where it’s asking for a bool?
Error:
Code Cell UNQ_C2: Unexpected error (NameError("name 'd' is not defined")) occurred during function check. We expected function
sq_dist to return type <class 'bool'>. Please check that this function is defined properly.
Hi @SameeraPerera,
Please ensure that no variables are hard-coded and verify that the sq_dist
function returns a boolean value, not None
or any other type. Also, make sure that you define functions and variables correctly!
Hope it helps! Feel free to ask if you need further assistance.
1 Like
Hi @SameeraPerera
The reason for
is probably because you missed the hint section
While a summation is often an indication a for loop should be used, here the subtraction can be element-wise in one statement. Further, you can utilized np.square to square, element-wise, the result of the subtraction. np.sum can be used to sum the squared elements.
So in case you hard-coded the path. The correction requires you to do the element-wise subtraction and to this you apply np.square and then tuple again and apply np.sum to resolve the code in single line.
Regards
DP
Thanks @Deepti_Prasad @Alireza_Saei
I just resubmitted it and it worked without making any code changes. I have seen this happen once before; possibly a temporary issue with the engine(?)
2 Likes
then probably the cell in question wasn’t run down (or kernel crashing) before submission and on re-submitting you must have run all the cells again as you have successful submission.
Regards
DP
You’re welcome! I’m glad to hear that your problem has been resolved.
As a tip, when you are confident in your written code but encounter errors from the grader, it can be helpful to resubmit the code a couple of times. Sometimes minor issues or glitches in the submission process can cause unexpected errors.