Closed sduquemesa closed 2 months ago
I think this explains some of the issues I've been having. Here's my minimal case, but I'm not sure if this is expected behaviour or not:
import mrmustard as mm
from mrmustard.lab import Fock
mm.settings.AUTOCUTOFF_MIN_CUTOFF=5
display(Fock((1,))._cutoffs is None)
display(Fock((1,)).fock)
I get:
True
array([0.+0.j, 1.+0.j])
Which I would have thought should obey the AUTOCUTOFF_MIN_CUTOFF setting. It seems that the state ket is determined at instantiation time without reference to the global setting. So even when using it later when applied to states, this instantiation time cutoff is used.
@aplund, I think it's a misunderstanding of what autocutoff means. In MM the autocutoff methods are triggered when a Gaussian state goes from (cov,means) to Fock. Here you already start with a Fock object, so autocutoff is not involved.
I think you understood that it's a global range that everything in Fock is subject to? We could support something like that if needed.
Before posting a bug report
Expected behavior
Mr Mustard automatically determines the same fixed cutoff value for all states or it keeps the value set with
settings.AUTOCUTOFF_MIN_CUTOFF
andsettings.AUTOCUTOFF_MAX_CUTOFF
.Actual behavior
States have different matrix size due to different cutoff values hence raising errors when performing math operations between states.
Reproduces how often
Sometimes when cutoff values are not explicitly defined.
System information
Source code
Tracebacks
Additional information
Notice the following code works correctly by explicitly defining the cutoff values and making sure they agree with
settings.AUTOCUTOFF_MIN_CUTOFF
andsettings.AUTOCUTOFF_MAX_CUTOFF