Codercise N.1.1

Hi Xanadu Codebook Team,

Please can someone help with this error on Codercise N.1.1. Not sure if it is due to some coding mistake I made or an incorrect setup.

When I run my solution directly in the Codebook, I am getting the red error:

Error: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()

I also tried on my local machine which does not show this error. Both are running PennyLane v0.34.0 and NumPy v1.26.3. Verified by printing print( qml.__version__) and print(qml._np.__version__).


Hello @maximus!

Welcome to the forum! The appearance of this error is indeed kind of weird, I’ll try to take a look at the source code, because that error shouldn’t be there.

However, your code isn’t quite correct! I’ve tried this with the correct solution in my browser and all works well.

Hint: Did you forget to complex conjugate something? :thinking:

Cheers,

Alvaro

1 Like

Thanks was able to get it right!

1 Like

hi @maximus!

i’m having the exact same problem as you did hahaha. What did you do to solve it?

Hi @gus_balvd In outer product, we assume the second argument goes from ket to bra. This involves conjugate and transpose. Looks like numpy does one of these under the hood!

1 Like

Hey @gus_balvd! Welcome to the forum :grin:

Yes, as @maximus said, you are not calculating the outer product correctly.
try np.conj() to get the the bra notation.
| i > < i | is the projection rather than | i > | i >.

A new character! :boom:

Welcome to the forum @cxMoonGlade :grin: