Module 'pennylane' has no attribute 'NumberOperator'

I tried to run the example at: https://pennylane.readthedocs.io/en/latest/tutorials/plugins_hybrid.html

@qml.qnode(dev_fock)
def photon_redirection(params):
qml.FockState(1, wires=0)
qml.Beamsplitter(params[0], params[1], wires=[0, 1])
return qml.expval(qml.NumberOperator(1))

But I got an error: module ‘pennylane’ has no attribute ‘NumberOperator’
I am using pennylane 0.4

Thanks!

Hi @cubicgate,

That’s unusual. Can you confirm your pennylane version by running the following command from within the same interactive python interpreter that you use to get the error?:

import pennylane as qml
qml.about()

Hi Nathan,

I found out the reason: on my computer, it is called NumberState.

Hi @cubicgate,

I figured out the issue. We’ve renamed a few operators in the latest development version of PennyLane, but this hasn’t made it into an official release yet. At the moment, the docs, by default, point to the development version, so there is some misalignment. This should be fixed shortly; we will release a new official version. Then the documentation will be up-to-date.

Nathan

Yes, thanks @nathan for your help!