Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Detect duplicate calls of method modify_parameters #1278

Open
eraviart opened this issue Oct 14, 2024 · 1 comment
Open

Detect duplicate calls of method modify_parameters #1278

eraviart opened this issue Oct 14, 2024 · 1 comment
Labels
kind:feat A feature request, a feature deprecation

Comments

@eraviart
Copy link
Member

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
Copy link
Member

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]

@bonjourmauko bonjourmauko added the kind:feat A feature request, a feature deprecation label Oct 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind:feat A feature request, a feature deprecation
Projects
None yet
Development

No branches or pull requests

2 participants