I honestly don’t know what is wrong here and would love some help and explanation.
{moderator edit - solution code removed}
I honestly don’t know what is wrong here and would love some help and explanation.
{moderator edit - solution code removed}
It looks like you must have hacked on that test cell in a way that broke it. The function one_hot_matrix_test
takes a function as its argument, but you have passed it the invocation of a function. It should not be necessary to change any of the test cells. When the tests fail, the right strategy is not to change the tests, but to figure out why your code fails the test. Although it looks to me as if your actual function code is correct.
You can get a clean copy of the notebook and use that to restore the test code to its original state.
Ok, wait a minute, I just tried to modify that test cell and it is not editable. That’s the way they normally set up the test cells to avoid this type of problem. So you must have really gone to some trouble to make that change. E.g. you must have downloaded the notebook and edited it with some other tool than the course website or have gotten it from some other source than the course website and uploaded the modified version.
So how did this happen? Just curious …
Yeah so I had downloaded the ipynb and uploaded it to Google Colab as I do with many of the other notebooks as I am more used to Colab’s environment. Before this issue I haven’t run into any similar issues. I don’t remember editing the testing cell code, so I do think that your analysis is likely correct, thanks a lot. Also, to whoever removed the image I posted that’s my bad, I forgot that posting any solution code is prohibited
Be advised: Working on a course notebook in Colab and then uploading it back into Coursera Labs is almost certain to alter the metadata in ways that can break the grader.
It is not a recommended practice.
Interesting. Thanks for giving us the background. As Tom says, we’ve seen examples where Colab messes with the metadata in ways that are pretty disastrous w.r.t. the course graders, but that does not account for the change to the test code. I don’t think there is any explanation for that other than deliberate action on your part, even if those keystrokes are no longer “in memory” …
I removed the code, but it was pretty helpful to see in this case. No harm done as long as we don’t leave it up there for posterity. As I mentioned, your actual solution code looked correct to me.
I hope you’re back to the original version and that things are working now.
Awesome, thanks for the help and explanation to go along with it.
If you prefer working in the Colab environment and know how to adjust things to make that work, your best bet is not to re-upload the IPYNB file back to Coursera. But you can just “copy/paste” over your completed code from the Colab version into the native Coursera version and that should be fine.