Autograder gives an error even though output matches expected output

The problem is that there is more than one test there. You can see the output of the first test, but the others are contained in the file The problem is the way you have copied the input params variable. That is a dictionary, but you did a simple copy. That does not actually copy the entries in the dictionary, which in this case are numpy arrays which are python objects. So you are actually updating the global variables that are being passed in. That’s why the second set of tests failed: you’ve modifed the input values.

Here’s a thread which discusses this point in more detail. The “TL;DR” is that you need to use “deepcopy” not simple copy. That’s the cleanest solution or you can individually copy the entries in the params dictionary. Or you can rewrite the code not to use the “in place” operator += to do the individual updates. That is explained on that other thread.