Detect duplicate calls of method modify_parameters
eraviart opened this issue · 1 comments
eraviart commented
When method Reform.modify_parameters
is called twice, the second call resets the changes made by the first call. It is not a bug, but it can cause hard to debug errors.
For example, this bug occurred here.
It would be nice if a warning was added when method modify_parameters
is called more than once.
bonjourmauko commented
Hi @eraviart ! I'm not very familiar with that method. Should it allow for commutative modifications at all?
I see the code modifies the global state, maybe we can pass around a State
monad, or a list, to keep track of the changes:
def modify_parameters(fun: ParamSpec, ctx: Sequence[ParameterNode]) -> Sequence[ParameterNode]:
# ...
return [new_node, *ctx]