~/work/W1A1/test_utils.py in multiple_test(test_cases, target)
121 print(‘\033[92m’, success," Tests passed")
122 print(‘\033[91m’, len(test_cases) - success, " Tests failed")
→ 123 raise AssertionError(“Not all tests were passed for {}. Check your equations and avoid using global variables inside the function.”.format(target.name))
AssertionError: Not all tests were passed for proportion_treated. Check your equations and avoid using global variables inside the function.
Can someone please help me understand what Im doing wrong. Thank you
I’m confused then. I thought from the thread title there was an error being thrown. The linked thread describes the same error, and a work around. Just matching the numeric value doesn’t seem to be enough for this unit test. Maybe I misunderstood.
Here’s the relevant section of the post I linked above …
Can you check the data type of the return value according to the error message? For example, you can check with type().
If the data type is float, can you wrap it with np.float64() and execute the code cell again?
In the docstring of the function proportion_treated(), the return value is stated as float, but when I checked the test function proportion_treated_test(), it seemed that the test case is prepared with np.float64() data type.
In addition, you can refer to the code of proportion_treated_test() in public_tests.py in the Lab files of your Coursera workspace.
my emphasis added
The workaround seems to be to coerce the type returned from the function from plain float to float64. Seems worth a try, no?
NOtE: that thread is almost 5 months old and this seems to be only the second time anyone is reporting this specific problem, so maybe there is something in common with these two implementations that causes the problem. Still, if the numeric value is equal and the only issue is the precision / type, it’s an easy workaround.