For C2_W1_Assignment Exercise 4 All Test Case Passing Except One

For C2_W1_Assignment [Optimizing Functions of One Variable: Cost Minimization] Exercise 4 All Test Cases Passing Except 1 , getting following issue:

Test for index i = 5. 
 7  Tests passed
 1  Tests failed

I tried rounding up the value set in dLdOmega_of_omega_array function. But same issue.

1 Like

Hi @Nitya_V. Welcome to the community!

Your output is very close to the expected output. Have you tried running the cell again?

If it still doesn’t work, can you privately send me your code? Thank you.

Yes, i have tried running multiple times. But output is same.

Attached the solution file which i have submitted for your reference.
{moderator edit: file removed}

Hi @Nitya_V.

The small problem was propagated way back to Exercise 2 where you are to build the f_of_omega function.

There are two things that you can try:

  1. Try using ‘float64’ (which is the default) instead of ‘float32’
  2. Try to rewrite this function with only 1 line of code (recommended). Because Python already does matrix operation, i.e. matrix multiplied by scalar, and there is no need to write a for loop for each value of the prices to calculate f_of_omega. But as far as I know, your function still works fine. I’m just not sure if it will pass all the tests.

Let me know if it works. Thanks!

Thank You Jonathan for inputs.
I will try them.

Hi, I also face this kind of error, but it cannot pass from one test that result is different in tiny value, what you can advice?

Please I also have the problem, how am I going to solve it, I’ve tried running again and again