Use __matmul__ (@) for the operator product
Created by: femtobit
Python has (since PEP 465) a matrix product operator __matmul__
(@
) distinct from __mul__
(*
) which is commonly used for element-wise multiplication.
Since this is a widely adopted convention in Python (in particular numpy), it makes sense for us to follow it as well, which is proposed in this PR. Then, expressions such as
id = -1j * sx @ sy @ sz
have the same semantics for NetKet operators as for numpy arrays.
Note that numpy.ndarray
uses @
in this way, while the numpy.matrix
uses *
but is deprecated.
This PR also replaces the occasional return NotImplementedError
with actually raising the exception.