I noticed that if no inputParameters dict is supplied to flip.evalute via the Python bindings, the default argument is used. Since the default argument only exists one time in memory and is mutated, this leads to unexpected results for subsequent calls.
Execute python reproduce.py. The script calls flip.evaluate from Python with no custom input parameters. For the first call, Flip will calculate start/stop exposure (in this case nan) and will store them in the inputParameters before returning them. The second flip does not supply its own inputParameters, but since the default argument was mutated in the previous call, the values from the previous call are used. This leads to different results:
Expected behavior
When not providing own inputParamaters, all calls to flip.evaluate should use defaults.
Flip should not reuse the computed start/stop exposure and other parameters.
Workaround
There is a workaround by passing an empty parameters dict to flip.evaluate in Python (see also workaround.py). This works as expected:
Hi,
I noticed that if no inputParameters dict is supplied to flip.evalute via the Python bindings, the default argument is used. Since the default argument only exists one time in memory and is mutated, this leads to unexpected results for subsequent calls.
Steps to reproduce:
python reproduce.py
. The script calls flip.evaluate from Python with no custom input parameters. For the first call, Flip will calculate start/stop exposure (in this case nan) and will store them in the inputParameters before returning them. The second flip does not supply its own inputParameters, but since the default argument was mutated in the previous call, the values from the previous call are used. This leads to different results:Two flip calls:
Skipping the first flip call:
Expected behavior When not providing own inputParamaters, all calls to flip.evaluate should use defaults. Flip should not reuse the computed start/stop exposure and other parameters.
Workaround There is a workaround by passing an empty parameters dict to
flip.evaluate
in Python (see alsoworkaround.py
). This works as expected:I filed a PR with a proposed fix: #33