Technical Prpblem with the assestment

in this cell it do not end it take more than an hour running but not finishing
i can not complete my task because of it

this course

week 3
assestment 2

THIS CELL IS NOT EDITABLE

UNIT TEST

def insert_audio_clip_test(target):
np.random.seed(5)
audio_clip, segment_time = target(backgrounds[0], activates[0], [(0, 4400)])
duration = segment_time[1] - segment_time[0]
#print(f"xx: {segment_time}“)
assert segment_time[0] > 4400, “Error: The audio clip is overlapping with the first segment”
assert duration + 1 == len(activates[0]) , “The segment length must match the audio clip length”
assert audio_clip != backgrounds[0] , “The audio clip must be different than the pure background”
assert segment_time == (7286, 8201), f"Wrong segment. Expected: (7286, 8201) got:{segment_time}”

# Not possible to insert clip into background
audio_clip, segment_time = target(backgrounds[0], activates[0], [(0, 9999)])
assert segment_time == (10000, 10000), "Segment must match the out by max-retry mark"
assert audio_clip == backgrounds[0], "output audio clip must be exactly the same input background"

print("\033[92m All tests passed!")

insert_audio_clip_test(insert_audio_clip)

The template code for insert_audio_clip as given to you puts a limit of 5 iterations on the for loop there to check for overlaps. Did you perhaps modify that code, so that it becomes potentially an infinite loop?

Put a print statement in the loop to see how many times it is being executed.

Note that this is not a problem with the grader cell, which you can’t edit in any case. It is a problem with your code.

1 Like

I agree with Paul, the most likely issue is that your code contains an infinite loop.

The interesting thing is that we just saw another student have this exact same problem in the last 24 hours and it’s one that I don’t think I’ve seen before. They give you the code in the template to make sure the loop terminates after at most 5 tries, but the other student removed that limit.

Note that there are two test cases in the test cell for insert_audio_clip and the second one specifically tests the way that the limit of 5 retries works: it gives you an impossible scenario that always overlaps. So you can’t eliminate that logic in your insert_audio_clip function. They gave it to you and you need to leave it there as part of the code.