I have done the one_hot_matrix_test and got all tests passed and the right output. Then when I run the next cell for new_y_test and new_y_train I get an error.

ValueError: Shape must be rank 1 but is rank 0 for ‘{{node Reshape}} = Reshape[T=DT_FLOAT, Tshape=DT_INT32](one_hot, Reshape/shape)’ with input shapes: [6], .

Why do I get all tests passed but there is still an error?

You don’t have to put it literal, you have use the way to get the shape.
one_hot = tf.reshape(tf.one_hot(—, —, axis=0), (—,))
Here is a clue: depth – (int) Number of different classes that label can take

Thanks, this helped a lot.
I implemented the same but as two lines but the grader didn’t accept it.
one_hot =tf.one_hot(-, -, axis=0)
tf.reshape(-,-)
It should be one line so the structure of the output is the same as requested.
Is this a bug from old version of TensorFlow or the way of implementation?

I would also add here that numpy reshape and tensorflow reshape have slightly different syntaxes at times. I run into a similar bug because of using old syntax.