Long lines cause recursion errors in parsing
Overly long katscript lines create recursion errors during parsing.
MWE
import finesse
import numpy as np
samples = 2000
phases = np.linspace(-720, 720, int(samples))
model = finesse.Model()
model.parse(
"""
m m1 R=0.9 T=0.1
"""
)
model.parse(f"sweep(m1.phi, {list(phases)}, True)")
Note that recursion limits are platform dependent, you might have to up the number of samples to hit it.
Since the parser depends on recursion, there is nothing to fix, but we could provide a better feedback than RecursionErrror
. Pointing users towards the python interface solves the problem
import finesse.analysis.actions as fac
output = model.run(
fac.Sweep(model.m2.phi, phases, True)
)
So we could do a rough check on line sizes and total input size and warn people appriopriately