C1_W2_Assignment - Programming Assignment: System of Linear Equations Error

I am submitting the program assignment. My program has correct output, but when I test using the unit tes , the following error is displayed.

[[ 1 2 -1 -1 3]
[ 0 1 4 3 22]
[ 0 0 1 3 7]
[ 0 0 0 1 1]]

Expected Output

[[ 1 2 -1 -1 3]
[ 0 1 4 3 22]
[ 0 0 1 3 7]
[ 0 0 0 1 1]]

Test your solution

w2_unittest.test_augmented_to_ref(augmented_to_ref)

Test case “identity_matrix”. Wrong output matrix. Check row reduction operations.
Expected:
[[ 0 1 0 0 1]
[ 0 0 1 1 2]
[ 2 -1 1 -2 0]
[ 0 0 0 -1 0]]
Got:
[[ 1 2 -1 -1 3]
[ 0 1 4 3 22]
[ 0 0 1 3 7]
[ 0 0 0 1 1]]
3 Tests passed
1 Tests failed

How Can I resolve this error to complete the assignment. Kindly advise, if I miss any code or instructions.

Thanks
Regards
Anoop Mathur

Hi @Anoop_Mathur,
Thank you for posting!
Could you please check again the arguments when calling the functions ‘AddRows’, ‘SwapRows’ and ‘MultiplyRow’?

Hi Degeye,
The parameters are correct, because code is giving me expected solution and unit tests are also passed
Original matrix:
[[ 1. -2. 3. -4.]
[-5. 6. -7. 8.]
[-4. 3. -2. 1.]
[ 8. -7. 6. -5.]]

Original matrix after its third row is multiplied by -2:
[[ 1. -2. 3. -4.]
[-5. 6. -7. 8.]
[ 8. -6. 4. -2.]
[ 8. -7. 6. -5.]]

Original matrix after exchange of the third row with the sum of itself and first row multiplied by 4:
[[ 1. -2. 3. -4.]
[ -5. 6. -7. 8.]
[ 0. -5. 10. -15.]
[ 8. -7. 6. -5.]]

Original matrix after exchange of its first and third rows:
[[-4. 3. -2. 1.]
[-5. 6. -7. 8.]
[ 1. -2. 3. -4.]
[ 8. -7. 6. -5.]]
Expected Output
Original matrix:
[[ 1 -2 3 -4]
[-5 6 -7 8]
[-4 3 -2 1]
[ 8 -7 6 -5]]

Original matrix after its third row is multiplied by -2:
[[ 1 -2 3 -4]
[-5 6 -7 8]
[ 8 -6 4 -2]
[ 8 -7 6 -5]]

Original matrix after exchange of the third row with the sum of itself and first row multiplied by 4:
[[ 1 -2 3 -4]
[ -5 6 -7 8]
[ 0 -5 10 -15]
[ 8 -7 6 -5]]

Original matrix after exchange of its first and third rows:
[[-4 3 -2 1]
[-5 6 -7 8]
[ 1 -2 3 -4]
[ 8 -7 6 -5]]

Test your solution

w2_unittest.test_elementary_operations(MultiplyRow, AddRows, SwapRows)
All tests passed

Hi @Anoop_Mathur,
Please, may you check again the code inside your helper functions (MultiplyRow, AddRows, SwapRows)?
Have a nice day!
Regards,
Stephane

Hi @Anoop_Mathur, did you find a solution to your issue?
have a nice day!

Kind regards,
Stephane Degeye