Skip to content

Allow adding an operator and it's (lazy) transpose

Vicentini Filippo requested to merge pv/fix into master

Created by: PhilipVinc

From the recently opened issue I noticed that right now neteket complains if you try to add an operator and its lazy transpose/hermitian.

The issue arises because he does not know that he can take the obj.dtype of those types... I fixed it now.

>>> a+a.H
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/filippovicentini/Dropbox/Ricerca/Codes/Python/netket/netket/operator/_local_operator.py", line 241, in __add__
    op = self.copy(dtype=np.promote_types(self.dtype, _dtype(other)))
  File "/Users/filippovicentini/Dropbox/Ricerca/Codes/Python/netket/netket/operator/_local_operator_helpers.py", line 42, in _dtype
    raise TypeError(f"cannot deduce dtype of object type {type(obj)}: {obj}")
TypeError: cannot deduce dtype of object type <class 'netket.operator._lazy.Adjoint[<class 'netket.operator._local_operator.LocalOperator'>]'>: Adjoint(LocalOperator(dim=1, acting_on=[(0,)], constant=0.0, dtype=float64))

This is now addressed

Merge request reports