C2_W1_Assignment: Grader Time Out Error on Exercise 4

Hi all,

My solution to exercise 4 takes ages to run, and upon submission I am getting grader time out error. One test is also failing due to (it seems) floating point precision issues.

Here is the function in question:

def dLdOmega_of_omega_array(omega_array, pA, pB):
N = len(omega_array)
dLdOmega_array = np.zeros(N)

for i in range(N):
    ### START CODE HERE ### (~ 2 lines of code)

{Do not post codes that will grade your assignment-Removed by moderator}
### END CODE HERE ###

return dLdOmega_array

Any help you can offer is much appreciated!

1 Like

Please post a screen capture image of the entire function.

I ask because I wonder if the indentation shown in your text copy-and-paste is correct.

If such, then codes can be shared in DM with mentor and mentor can respond here with the issue were correction is required, @Asad_Ali8

Share the image of the grader output @Asad_Ali8

Based on your grader output and the codes you shared, you have hard code the path leading to Grader time out

Hint:Recall in a way so the same array should not loop again and again

@Asad_Ali8, I don’t see any issues in the code you originally posted.

So the next place to look for problems is in your code for the f_of_omega() function, which is called by L_of_omega().

For those who find this thread later:
The issue was errors in the f_of_omega() function.

1 Like

Hello @Asad_Ali8

First of I am sorry for delayed response and as @TMosh stated your def dLdOmega codes are actually correct and he mentioned issue lies with

def f_of_omega(omega, pA, pB):
your code is incorrect here. See the below image where it mentions to calculate f_of_omega there is simple addition operator required and nothing else. It is L_of_omega where array of f_of_omega is done but you have used numpy array to f_of_omega with zip code for a, b, this is not required. Hint: below image first sentence will give you, on how to do the correction

Let me know, if you still have issue.

Regards
DP

1 Like

Thank you @Deepti_Prasad. The issue is resolved now. As you pointed, the error was in my f_of_omega function.

1 Like

M sorry I didn’t read Tom’s last msg. :woman_facepalming:

Regards
DP