Hi,
During execution of
# UNIT TESTS
split_dataset_test(split_dataset)
Error is
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-11-197878478053> in <module>
31
32 # UNIT TESTS
---> 33 split_dataset_test(split_dataset)
~/work/public_tests.py in split_dataset_test(target)
79 'right': np.array([2, 7, 9, 10])}
80
---> 81 assert np.allclose(right, expected['right']) and np.allclose(left, expected['left']), f"Wrong value when target is at index 0. \nExpected: {expected} \ngot: \{left:{left}, 'right': {right}\}"
82
83
I found that one of the unit test is wrongly written, because of this its failing.
Test case form public_tests.py
# Case 3
X = (np.random.rand(11, 3) > 0.5) * 1 # Just random binary numbers
X_t = np.array([[0, 1, 0, 1, 0, 1, 1, 0, 0, 0, 0]])
X = np.concatenate((X, X_t.T), axis=1)
left, right = target(X, [1, 2, 3, 6, 7, 9, 10], 3)
expected = {'left': np.array([1, 3, 6]),
'right': np.array([2, 7, 9, 10])}
assert np.allclose(right, expected['right']) and np.allclose(left, expected['left']), f"Wrong value when target is at index 0. \nExpected: {expected} \ngot: \{left:{left}, 'right': {right}\}"
print("\033[92m All tests passed.")
From above code you can see that right and left arrry values are not correct
From code
X_t = np.array([[0, 1, 0, 1, 0, 1, 1, 0, 0, 0, 0]])
you can see indices for value 1
are 1,3,5,6
and for 0
are 0,2,4,7,8,9,10
which are not matching with left and right arrays used for verification.
In code
expected = {'left': np.array([1, 3, 6]),
'right': np.array([2, 7, 9, 10])}
Can someone please fix this test case? or let me know if my understanding is not correct here.
Thanks