fipy icon indicating copy to clipboard operation
fipy copied to clipboard

Remove mutable default arguments

Open guyer opened this issue 3 years ago • 0 comments

As documented (under "Default parameter values are evaluated from left to right when the function definition is executed"), using mutables as default arguments can have unexpected results.

This is done in most of the Viewer definitions (limits={}), as well as a handful of other cases.

As documented:

A way around this is to use None as the default, and explicitly test for it in the body of the function

See also https://stackoverflow.com/questions/26320899/why-is-the-empty-dictionary-a-dangerous-default-value-in-python.

guyer avatar Jan 13 '22 15:01 guyer