Faulty unit tests in grading assignment for C2_W1: Impossible to pass

There are 2 faulty unittests for

1. Graded_function_2: get_count
Key ‘expected_n_words’ referred to in line 167 of w1_unittest.py is not present in the dictionary test_cases initiazed in line 109. This is causing error while running unit-tests, leading to grading failure.

2. Graded_function_11: min_edit_distance
Expected cost matrix (D) for 4rth (last) test case with source word ‘star’ and target word ‘stack’ is inocrrect. It has first row as 0, 2, 4, 6, 8, 10 and first column as 0, 2, 4, 6, 8, which is not possible. There is different (correct) expected cost matrix (D) for the same pair of words in 3rd test case. Hence, this test case always fails.

Due to this faulty unittests I am unable to pass the C2_W1 assignment. Kindly please look in to this.

Thanks in advance.

1 Like

Hello @Kuldip16!

Maybe resetting the notebook can help, please keep a copy in order not to lose your solutions.

Instructions can be found here:

1 Like

@Anna_Kay Thank you for looking in to this.

Tried reseting my notebook following this steps. Still getting the same error while running the unit tests.

1 Like

The course has used those unit tests for several years. It is unlikely you’ve discovered a previously unknown error in the unit tests.

Hi @Kuldip16

Check debug steps

To get word count dictionary, make sure you used the hint below mentioned in the assignment before the grade cell where correct argument word_l is set of corpus used to to get the word count dictionary.

If the above codes is as per instructions, then check
UNQ_C1 GRADED FUNCTION: process_data
def process_data(file_name)
where you recalled codes correctly for
Convert every word to lower case and return them in a list. Below is hint instruction

  • For the pattern, decide between using ‘\s’, ‘\w’, ‘\s+’ or ‘\w+’. What do you think are the differences? (I SUPPOSE THIS IS WHERE THE ISSUE LIES WITH YOUR CODE)

Let me know if you used the correct argument in the process_data grade cell where you used the right argument i.e. file_name and function read()
Then use set.lower() to convert to lowercase.

Let me know if you still need any further help!!


Thank you for looking in to this.

I have checked all the hints. Tried everything. Its been 4 weeks. No resolution. Please try to check the exact issue I have reported. There is a key being referred to in w1_unittest.py which is not in the dictionary definition. My course subscription has ended.

I am thankful to people responding here but no one is trying to address original issue I have reported.

Its very frustrating. No help from @DeepLearning.AI-Team. No way to get any help on coursera.

Can you share the screenshot of the error here once?

That just means there are bugs in your code. One likely cause is referencing global variables, instead of the parameters passed to your functions. If you are unable to debug these issues, we can look at your code, but we’re not supposed to do that in a public thread like this. I’ll send you a DM about how to proceed.