C1_W2_Assignment_ Help

Hello,

5/6 Exercises passed correctly.

But in Exercise 6 despite using same functions (defined earlier & unit tests passed) and methods the answer does not match.
I have checked and my inputs to my functions are as per the line instructions given.

What next step can I take to debug?
I have saved my notebook & downloaded it. Hope it wont delete my progress.

hello roy,
I just finished this course and want to help you. But your question is little bit vague, could you share the code via picture. I think it would be easier for others to check.

Hello Zhang,

Thank you for offering to help.
Here are the code snippets you asked for:

The **FUNCTIONS**

### START CODE HERE ###
# moderator edit: code removed - not allowed by the Code of Conduct.
### END CODE HERE ###```

Code which does not pass the unit tests:

def ref_to_diagonal(A_ref):
### START CODE HERE ###
# moderator edit: code removed - not allowed by the Code of Conduct.
### END CODE HERE ###

return A_diag

A_diag = ref_to_diagonal(A_ref)

print(A_diag)


My Output:

[[  1.   0.  -9.  -7. -41.]
 [  0.   1.   4.   3.  22.]
 [  0.   0.   1.   3.   7.]
 [ -0.  -0.  -0.   1.   1.]]

Expected Output:

##### __Expected Output__

```Python
[[1 0 0 0 2]
 [0 1 0 0 3]
 [0 0 1 0 4]
 [0 0 0 1 1]]

No, doing that would break the Code of Conduct.

Oh, you are right.
Thank you for pointing out and rectifying my post.

@Hassan_Zhang Apparently that would violate the code of conduct. :frowning:
Initially I had provided the code snippets but @TMosh removed those.

oh… so what should we do to let others understand what error we are facing? and even screenshot of code is not allowed?

The first thing to realize is that the tests in the notebook don’t check for every possible defect.
It’s very common to pass the notebook tests but still fail the grader, because the grader uses different data and different conditions.

So the first thing to check is always verify that your code will work with any size of data set and any initial conditions. Avoid hard-coding any values or dimensions that aren’t explicitly given in the assignment instructions. Avoid using any global variables that the grader will not have access to.

You can post your error messages and any assert logs that appear when you test your code. This is often sufficient to identify the cause of the problem.

Hopefully a mentor for this course will be able to answer specific questions. I’m not a mentor for this course, and I do not have access to the materials.

Yes, sharing your code is not allowed.

Here are the ERROR MESSAGES I received for Exercise 6:

Test case "default_check". Wrong output matrix. Check row reduction operations. 
	Expected: 
[[1 0 0 0 2]
 [0 1 0 0 3]
 [0 0 1 0 4]
 [0 0 0 1 1]]
	Got: 
[[  1   0  -9  -7 -41]
 [  0   1   4   3  22]
 [  0   0   1   3   7]
 [  0   0   0   1   1]]
Test case "identity_matrix". Wrong output matrix. Check row reduction operations. 
	Expected: 
[[  1  -2   9 -20 -12]
 [  0   1  -4   9   6]
 [  0   0   1  -3  -2]
 [  0   0   0   1   1]]
	Got: 
[[ 1 -2  0  0 -1]
 [ 0  1  0  0  1]
 [ 0  0  1  0  1]
 [ 0  0  0  1  1]]
 2  Tests passed
 2  Tests failed

It seems I have to submit it with the errors hoping that I still get passing marks.
I rechecked the entire assignment multiple times and could not identify the bug. :worried:

Hi,

I was getting the same error as you.

I found out the reason was because in my call to the Addrows method, I was using:
A_diag = AddRows(A_ref, x, y, z)

I should have been using
A_diag = AddRows(A_diag, x, y, z)

For the first line of code in your ref_to_diagonal method you should also make a copy of the incoming matrix with:
A_diag = A_ref.copy()

Maybe this can help you.

Hi, I am facing the same issue. Any fix you found?