Course 4 Wk 1 unmarked exercises

When following through the unmarked Exercise 6 - create_mask_from_window
I got this result using the recommended array type code Output = (a == np.max(a))

and this got all tests passed as expected.
However when I ran the same function using the deprecated ‘for loop’ method;
mask = np.zeros((x.shape))
for i in range (f):
for j in range (f):
mask[i,j] = True if (x[i,j] == np.max(x)) else False

I got

Both methods pass the tests but each method produces a different output.
Looking at the output there seems to be two correct but different answers.
This is unscored so doesn’t matter in the course, but intrigues me.
Any helpful comments on where I am mistaken?
Notice the first method produces a 3 by 3 array and the second a 2 by 3 array


Got it - thanks - When using the array method I returned the wrong matrix to the calling function (misspelling!) although surprisingly all tests were passed.

Glad to hear that you found the answer on your own steam! It sounds like there may be some issues with the unit tests. I will bookmark this thread and try to find time to take a more detailed look sometime soon.

Hi Paul.
Truth is I am really enjoying this course and like to play around using different approaches to see what results I get. So I expect to find anomalies.