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

Modification of parameter with default #67

Closed
lazyoracle opened this issue Feb 28, 2021 · 1 comment
Closed

Modification of parameter with default #67

lazyoracle opened this issue Feb 28, 2021 · 1 comment
Assignees
Labels
code-quality General code quality related issues and PRs
Milestone

Comments

@lazyoracle
Copy link
Member

Describe the bug
Modifying the default value of a parameter can lead to unexpected results.

The default value of a parameter is computed once when the function is created, not for every invocation. The "pre-computed" value is then used for every subsequent call to the function. Consequently, if you modify the default value for a parameter this "modified" default value is used for the parameter in future calls to the function. This means that the function may not behave as expected in future calls and also makes the function more difficult to understand.

some_dict.pop() is used in several places in algorithms.py which leads to modification of defaults (ref here and here).

Remark
Is there some reason why pop() is used in place of standard dictionary access routines?

@lazyoracle lazyoracle added the code-quality General code quality related issues and PRs label Feb 28, 2021
@lazyoracle lazyoracle self-assigned this Feb 28, 2021
@lazyoracle
Copy link
Member Author

We pop out the key-value pairs from options that are not used/expected by the SciPy optimizer. We then pass this entire dict to the optimizer so that there are no incompatible keys in the dict.

@lazyoracle lazyoracle added this to the 1.3 milestone May 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
code-quality General code quality related issues and PRs
Projects
None yet
Development

No branches or pull requests

1 participant