Possible problem with W4 Assignment Exercise 3 - w4_unittest.test_matrix(P, X0, X1)

From my understanding, we are to fill in values for the P matrix where “All elements on the main diagonal should be equal to 0, and the entries in each column must add to one”. I performed this and got 1 error on the test “Wrong vector X1. Check if matrix multiplication was performed correctly.”. Looking through the unit test script I found where this test case is and it seems that it is expecting a vector that is within a very small tolerance of what is written in the test script. Once I changed column 4 of the P matrix to match the test case it passed.

I believe this is an error since the question prompt did not mention criteria for the values in P except that all diagonals are 0 and each column should sum to 1.

If I am mistaken please let me know.

2 Likes

I have encountered the same error. In my case, the unit test fails saying type of X0 variable is not numpy.ndarray. I checked the type via a simple print statement. It shows the type is what is expected.

However, in the Unit Test, it fails and says “Wrong Vector X1. Check if the matrix multiplication was performed correctly.”

Was this the case for you too?

1 Like

I did not receive the error that you mentioned “X0 variable is not numpy.ndarray”. So I am not sure why you are receiving that.

As for the other error that my post is about. If you look through the test file, you should be able to read what and how they are testing your code. That is how I figured out that there might be an error.

1 Like

Totally agree. I’ve just came up with the error and did the same thing. If we pick a 5x5 matrix that is too different from their test case, result is an error.

1 Like

Hi @Shawn_Mailo, @Abhijit_Chakraborty1 and @Nguyen_Duy_Anh !

We have updated this assignment to perform some fixes, could you guys please try to refresh your workspace?

Please tell me if this works.
Thanks,
Lucas

1 Like

I got the same error as yourself. But in the grader it said that the test case failed due to incorrect type of X0.

I too followed what you suggested and it worked. Thanks.

1 Like

Hey @lucas.coutinho, I tried refreshing the workspace and opened the latest version. I tried changing the values of matrix P but unfortunately it didn’t work.

Could you tell whether we can use any matrix P satisfying the given condition or not?

1 Like

yeah, it did not work for me too

1 Like

Anyway, I got 100 points :sweat_smile:

Hi, @Abhijit_Chakraborty1,

Yes, you can use any matrix given the conditions, so the test should be able to handle those cases. Can you send me, via DM, the matrix you’re trying to input? So I can investigate what is going on.

Thanks,
Lucas

1 Like

moderation edit - solution code removed
Hello, every one. please input this values for P(Transformation matrix). Resource: w4_unnitest.py

1 Like

For grading this does nto seem to be a problem since i got the full 100% from grader, but unittest still outputs
Wrong vector X1. Check if matrix multiplication was performed correctly. 6 Tests passed 1 Tests failed

the problem is within w4_unittest.py since in line 385 you there calculate the expected X1 to be your “expected P” @ “expected X0” and in the assrertion in line 404 you compare the target_t1 to expected_t1 with allclose so unless the user has collum 4 in his P matrix within 1e-5 of the ones in the expected p in the unittest this test will fail

1 Like

Thank you!
I also was stuck there and your matrix did the trick.

2 Likes

Hi all!

This is indeed a bug in the unittest code. I have already informed our Curriculum Engineer and this will be fixed soon. Thanks!

2 Likes

Thanks a lot for this post.

1 Like

I am receiving the same error as described in this post. Has it been fixed?? Should I continue hoping the grader will give me full credit? My P Matrix is:
P = np.array([
[0.00, 0.70, 0.35, 0.00, 0.35],
[0.10, 0.00, 0.25, 0.35, 0.20],
[0.30, 0.20, 0.00, 0.35, 0.15],
[0.55, 0.05, 0.30, 0.00, 0.30],
[0.05, 0.05, 0.10, 0.30, 0.00]
])

1 Like

I got the same error…I submitted the assignment and they actually did take a couple points off. I hope the mods correct the test bug. Thanks.

1 Like