Week 2 Programming Assignment: System of Linear Equations Problem

I am new with Python and Numpy, but I think I was able to finish the week 2 assignment. All the test pass, however, when I submit my assignment to be graded I got 70%. Two problems has an error (after submission) related to the return type. The two problems are 5 and 6 and the errors are:
For problem number 5
Failed test case: Variable x_1 has incorrect type…
Expected:
<class ‘float’>,
but got:
<class ‘NoneType’
For problem number 6
Failed test case: The output of the ref_to_diagonal function has incorrect type…
Expected:
<class ‘numpy.ndarray’>,
but got:
<class ‘NoneType’>.
I have tried to resubmit already but still got the same issue.
I attached the errors from the number 6

Hi @rvaldivieso ,

Although your code passed the unit tests, but the grader uses different test to verify if your code is done correctly.
The NoneType error could be due to return value is none. To debug, put a print statement in your code to check, for example, suppose we have a variable X,

to check if the variable X has any value:
print(’ X value:', X)

to check the datatype of variable X:
print(‘datatype of X:’, type(X))

Every time you make changes to the code, do remember to rerun your code. If your notebook has been inactive for a while, then, you need to rerun your code from start.

In addition to @Kic reply (which I agree with):

When you get mysterious errors from the grader on multiple functions, it’s often a logistical issue, not necessarily an error in your code.

Among the typical causes:

  • Renaming your notebook. The grader always uses the original notebook file name.
  • Trying to grade a partially completed notebook. It’s better if you complete the whole thing before grading because any “None” statements left in the notebook will make the grader unhappy.
  • Using an obsolete version of the notebook.
  • Using the notebook on an off-site platform (like Colab or VSCode), and then uploading the notebook back into Coursera for grading. This will almost always mangle the metadata that the grader uses.
  • Deleting a cell.
  • Adding a cell.
  • Deleting a cell by accident and then trying to recreate it. See my earlier comments about metadata issues.

Sadly, there is no way for me to fix the problem. I reset everything upload my answers, and nothing. I guess I will quit this course since it does not seem to work.

Hi @rvaldivieso ,

This course has been running for awhile, if there is any problem with the course’s grading system, it would have been ironed out. There must be some sort of coding issue here. If you click on my icon and attach your notebook in a private message to me, I will have a look for you.

The course works fine. It’s years old, and has been recently refreshed.

If you cannot fix the issue yourself, the mentors can help you.

Tip:
You cannot submit a renamed notebook for grading.
The grader always uses the original notebook name - regardless of what notebook you have open when you click on the “Submit” button.

Hi @rvaldivieso

There are a couple of errors in your code:

  1. ex1, wrong data type is used when creating the matrix A and b. You have not been given instruction to create the array in the datatype ‘float’. Your code set the dtype=float. Why do you do it? This is exactly the problem that the grader flagged in the error message. If we have x= np.array([1,2,3,4]), the array will be created in the datatype as the value given. In this case, int.
  2. ex5, your code should work out what the value of x1,x2,x3,and x4 according to the instruction given, however, your code just assigned a value to what you picked up from the expected output. That would not do, as the grader tested your code with different values, hence your code failed. Please follow the instructions and click on the Hints - where equations are given to help you work out those values.

Well those float values was my attempt to fix the problem. Before were just integer values like 1,2,3, 4 and it didn’t work for both questions.

Richard

Hi @rvaldivieso ,

It would be helpful to know exactly what changes you have made. I have changed the matrix into ‘int’, by removing the dtype argument in the np.array() call, and used the equations given under the hints to work out the values for ex5, and it works.

Also, every time you made some changes to the code, you need to rerun the code cell. To be sure the execution environment is clean, you can click the menu bar on the top of you notebook:
kernel → restart & clear all output
cell → run all